PHP Interview Questions and Answers
PHP earlier stood for Personal Home Pages, but now it stands for Hypertext Pre-processor. PHP is a server-side scripting language that is used for building web pages and applications. We have just added more questions in our question bank for PHP interview questions. This language includes many Frameworks and CMS for creating large websites. Even a non-technical person can create web pages or apps using PHP CMS or frameworks. PHP supports various frameworks and CMS that are used to develop applications.
Before getting confused with the plethora of PHP developer interview questions, you need to ensure the basics. This question will help you to understand the core basics of PHP and make you even more confident enough to jump onto the advanced questions.
Quick Facts About PHP | |
---|---|
What is the latest version of PHP? | 8.0.3, released on 4th March 2021 |
Who is the developer of PHP? | Rasmus Lerdorf |
What language does PHP use? | C language |
PHP License | It is a BSD-style license which does not have the "copyleft" and restrictions associated with GPL. |
- It runs on various platforms, including Windows, Mac OS X, Linux, Unix, etc.
- It is compatible with almost all servers, including Apache and IIS.
- It supports many databases like MySQL, MongoDB, etc
- It is free, easy to learn and runs on the server-side.
- PHP can operate various file operations on the server
Note: This is a list of the most frequently asked PHP interview questions. Please have a good read and if you want to download it, it is available in a PDF format so that you can brush up your theoretical skills on this subject.
Top PHP Developer Interview Questions
The aggregate function performs a calculation on a set of values and returns a single value. It ignores NULL values when it performs calculation except for the COUNT function.
MySQL provides various aggregate functions that include AVG(), COUNT(), SUM(), MIN(), MAX().
function IsPrime($n) {
for($x=2; $x<$n; $x++)
{
if($n %$x ==0) {
return 0;
}
}
return 1;
}
$a = IsPrime(3);
if ($a==0)
echo 'Its not Prime Number.....'."\n";
else
echo 'It is Prime Number..'."\n";
Both used to deploy your Java Servlets and JSPs. Apache is an HTTP Server, serving HTTP. Tomcat is a Servlet and JSP Server serving Java technologies.
- SOAP represent for Simple Object Access Protocol, and REST stands for Representation State Transfer.
- SOAP is a protocol and Rest is an architectural style.
- SOAP permits XML data format only but REST permits different data format such as Plain text, HTML, XML, JSON, etc
- SOAP requires more bandwidth and resource than REST so avoid to use SOAP where bandwidth is minimal.
In PHP, a friend function is one non-member function having access to private and protected members within a class. A friend function has the best use case when being shared among multiple classes, which can be declared either as member functions within a class or even a global function.
preg_replace('/\s/', '', 'Best Interview Question');
Primary Key | Unique Key |
---|---|
It is used to serve as a unique identifier for each row within a table. | Used to determine rows that are unique and not a primary key in a table. |
It cannot accept NULL values. | Unique Key can accept NULL values. |
There is the only scope for one primary key in any table. | Multiple Unique Keys can be defined within a table. |
The primary key creates a clustered index. | Unique Key creates a non-clustered index. |
Note: Our PHP interview questions for freshers have been selected from a plethora of queries to help you gain valuable insights and boost your career as a PHP Developer.
The items of an array can be sorted by various methods.
- sort() - it sort arrays in ascending order
- rsort() - it sort arrays in descending order
- asort() - it sorts associative arrays in ascending order, according to the value
- ksort() - it sort associative arrays in ascending order, according to the key
- arsort() - it sorts associative arrays in descending order, according to the value
- krsort() - it sorts associative arrays in descending order, according to the key
Inheritance has three types, are given below.
- Single inheritance
- Multiple inheritance
- Multilevel inheritance
But PHP supports only single inheritance, where only one class can be derived from a single parent class. We can do the same thing as multiple inheritances by using interfaces.
Note: Before getting confused with the plethora of PHP interview questions for experienced, you need to ensure the basics. This question will help you to understand the core basics of php and make you even more confident enough to jump onto the advanced questions.
Its properties cannot be declared final, only classes and methods may be declared as final. If the class or method defined as final, then it cannot be extended.
class childClassname extends parentClassname {
protected $numPages;
public function __construct($author, $pages) {
$this->_author = $author;
$this->numPages = $pages;
}
final public function PageCount() {
return $this->numPages;
}
}
Top 10 PHP Interview Questions
Here you will find the list of Top PHP interview questions, which were written under the supervision of industry experts. These are the most common questions and usually asked in every interview for the role of the PHP Developers.
- What are Design Patterns in PHP?
- What is the difference between abstract class & interface in PHP.
- What is traits & how it can we used?
- What is the use of .htaccess file?
- What is the difference between MyISAM and InnoDB?
- What is the difference between Public Private and Protected?
- What is Constructor and Destructor?
- What is final class and final method in PHP?
- What is a static member function?
- What is function Overloading and Overriding in PHP?