PHP Interview Questions
PHP, a general-purpose language which is released by Rasmus Lerdorf in the year of 1994. In starting, it is the small open source project but advanced with time as more people found it very useful. Now, the question arises, what PHP do? To know that, we gather some important questions which are described below. You will get all your answers by reading them. For now, let’s have some basic introduction about PHP.
PHP, aka "Hypertext Preprocessor" is a server-side scripting language which is designed mainly for web development. The basic functionality of PHP is to manage dynamic content, session tracking, and databases. It is also used in combination with different web template systems, web framework, and web content management system. Moreover, you can use PHP to build many e-commerce websites too. Thus, it is expected that the companies would like to hire developers who have good knowledge in PHP. To shine in interviews, you must answer all the questions asked by interviews. But you need not to worry, for your ease, below are some top collection of PHP interview questions that every interviewer asked. Read them and get a chance to get a great job.
What is mvc in PHP?Posted By: bookermontenegroPhp
MVC is a design pattern for creating applications that separate Business logic (Controller) and Application data (Models) from the USER interface (View). MVC is an acronym of Model, View Controller.
Write a program to upload files using curlPosted By: AbercormlenPhp
What is name of max execution time constant in php?Posted By: WinfredPhp
max_execution_time is of the constant that is used to increase the execution time of a script in PHP.
What is difference between echo and print in PHP?Posted By: VincentPhp
There are small difference between Echo and Print in PHP.
These are -
- Echo has no return value while Print has a return value of 1.
- Echo is marginally faster in comparison of Print.
- Echo can output one are more strings while Print can output only 1 string.
- Echo is a language constructor while Print is a function.
What is HTML DOM?Posted By: OranPhp
DOM (Document Object Model) is a Object Model for HTML. The Document Object Model (DOM) defines the logical structure of documents and the way a document is accessed and manipulated.
Explian the difference between cookie and session?Posted By: Akhil JoyPhp
How to create cookies via Ajax in PHP?Posted By: SimPhp
What is sql injection? What you do to prevent SQL Injection in PHP?Posted By: LymanPhp
Explain scope levels in PHP.Posted By: JigneshPhp
There are 3 different levels of Scopes are available in PHP. They are.
- Public: Public scopes allow you to access all data and functions of a Class.
- Private: Private scopes don't allow you to access the private data and functions of a Class.
- Protected: Protected scopes only allows its derived class to access the Protected data and functions of a Class.
Find the longest palindrome in a stringPosted By: BudPhp
What is difference between session and cookie?Posted By: EddierotPhp
The Major difference between sessions and cookies are -
- Sessions are stored in Server Side while Cookies are sotred in Client Side.
- Sessions are stored unlimited amount of Data while Cookies are Stored limited amount of Data.
- Sessions are holding multiple variables while Cookies are not holding multiple varibles.
- Sessions are more secure than Cookies.
- Sessions values are not easily accessible While Cookies values are easily accessible.
- Sessions can not disabled by visitor while cookies can disabled by the visitor.
How to get IP address of user in PHPPosted By: JosePhp
In your code simply use
$_SERVER['REMOTE_ADDR']to get the IP address of the client or User.
What is the full form of PHP?Posted By: Mohammed VajhullahPhp
The full form of PHP is Hypertext preprocessor (earlier called personal home page)
How to create object of Interface?Posted By: AsburyPhp
What is cross site scripting and how it can be prevented?Posted By: AllenPhp
Write pyramid structure without using PHP function ?Posted By: WinfieldPhp
What is difference between XAMPP, WAMP, and LAMPPosted By: GardnerPhp
The difference among XAMPP, WAMP and LAMP are -
XAMPP WAMP LAMP It is a combine Package of Apache, MariaDB,PHP and Perl. It is a combine Package of Apache, MYSQL and PHP. It is a combine Package of Apache MYSQL And PHP. It has compatible with all available operating system as Window, OS-X and Linux. It has limited only for windows operating system. It is a open source platform and Compatible with only Linux.
Tell me few diffrence between GET & POSTPosted By: Faisal alamgirPhp
Few difference between GET & POST is -
GET request remains in browser history while POST Request does not remain in browser history.
GET is availbale for retrieving data while POST is available for writing/Updating data.
GET have no side effects while POST have some side effects.
How to connect MongoDB using PHP?Posted By: HunterPhp
What is default session time in PHP? How to increase It?Posted By: LeonPhp
How can you connect a web page data with mysql ?Posted By: MichaelPhp
Explian the difference between preg_Match and preg_replace?Posted By: luciomontague9Php
preg_Match is the pattern, that is used for searching as a string, while preg_replace is the pattern, that contains the string which is used to search the content, which can be the array of string.
List the HTTP methods avalable in PHP?Posted By: SMKPhp
What is Interface? Why we use it?Posted By: HaydenPhp
What is difference betwwen PHP 4, 5 and 7?Posted By: B.V.SravaniPhp
What is difference between the include(), require(),require_once() functions in PHP?Posted By: Krishna KushwahaPhp
What are design patterns in PHP? Can you list few.Posted By: EnochPhp
What are Super Global variables in PHP?Posted By: RollinPhp
What is Php ini?Posted By: ElvisPhp
Code to send a mail with attachment using phpmailer?Posted By: LambertPhp
What is difference between CURL and AJAX?Posted By: HendersonPhp
How to set and Get a value in PHP Session.Posted By: AntonePhp
What is the usage of link() in PHP?Posted By: JigneshPhp
PHP vs ASP
It is faster
It is slower
It is easy to run
It is cumbersome to run
PHP vs Perl
It is easy and less confusing to use
It is very complicated
PHP can perform most of the Perl tasks in a simple way
Perl is very complicated and difficult for the users to use it
It is matured and evolved language.
It is a very tried and true language.
Pros of PHP
Low Barrier of Entry:
It is very easy to use PHP. Users find it very easy to make the web pages on it. Basically, PHP is designed to look after the priority of the simple building personal home pages and interpreting forms.
Functional and Object-Oriented Programming:
The current version of the PHP supports functional and object-oriented programming with anonymous functions which is also known by lambdas or closures.
PHP is surrounded by the gigantic ecosystem. It is because of the popularity of WordPress and Magento. You can get online training to learn PHP which is absolutely free. There are also local tutors who teach you all about the PHP.
A Multitude of Pluggable Frameworks:
The PHP community had introduced the PHP Framework Interop Group to include interoperability. This is important because this allows porting of code from one framework to another framework. This led to having many good frameworks like Laravel, Silex and many others who share common libraries.
A great number of automation tools are available for testing and deploying PHP application that are scripted in PHP
First Class Debugging:
It is possible for the PHP to perform high-class debugging which includes remote debugging. With the emergence of the Virtual machine world of Vagrant and Docker, it becomes more and more prominent. It can be possible because of Xdebug.
Cons of PHP
PHP is an interpreted language same as Python and Ruby that is organized down to Opcode. However, this problem is sorted to a very extent but warm up is still problematic.
Although the arrival of the FastCGI Process Manager (FPM), it's still a reservoir of threaded executors. Due to this, many types of scalability issues have to face. It bothers all of the threaded runtimes for other languages like Python WSGI, Ruby Rack, Java Servlets or Microsoft IIS.
Every thread has its own memory space. So, you have a limited amount of storage for the number of connections that you can support. Most of the language have asynchronous I/O solution available. PHP has React and Icicle but they don't have a meaningful install base.
PHP needs extension which works as a bridge between C code and PHP to be installed globally to the PHP feasible. To access the file, they require the modification of the global configuration file. Most of the other interpreted languages give assistance for libraries to implement extensions that can be installed by the package management tool. It is possible with the help of systems administrator. It also makes getting deploying available in treated application scenarios more complex.
Except for Node.js, every interpreted language has their minimal IoT (Internet of Things) community but for PHP it seems like there is none. If there is one it is hiding. It is because of the shortage of well-established asynchronous I/O framework which is necessary to handle I/O well
Hiring PHP Developers:
As there are fewer restrictions of entry and having no concept of "Senior PHP Developer" gives a real hard problem finding good talent in PHP. It is hard to find the top-level developer whereas compared to the other languages.
As already explained the barrier of entry is low and having the popular and legacy code bases such as WordPress, the world is feeling it as an insecure and entry-level language. Moreover, PHP has not acknowledged cool in over ten years. This can cause problems for both the developers and companies.
In resume, your value and marketability as a developer of PHP can be reduced if it is all filled with PHP.
In the case, if you want to sell your company with having an average level developer, it appears more financially viable to the buyer than having the team of the best PHP engineers. Therefore, if you want to raise the value of your company, then try to have a team of Node.js and java experts
With the emergence of the PHP Framework Interop Group around five years ago, the PHP community has finally embraced interoperability. This allows writing code for one framework that can be more easily ported to another. It also means you can use many of the same libraries across frameworks. Interoperability also means that core components are shared and it becomes easier to build and maintain a framework while focusing on the use case for your framework rather than the core components that every framework must provide. This has led to an abundance of really good frameworks like Symfony2, Laravel, Silex, and Zend-expressive that share common libraries.