Top 10 PHP Interview Questions asked to test your PHP skills- woknrby

The business world has completely changed and with this change, the demand for PHP jobs is also attracting the interest of youth. So, in today’s article, keeping in mind the trend of PHP job profiles, we’ll discuss the top 10 questions answers that a candidate appearing for an interview for PHP developer profile, should know as the part of basic PHP knowledge.

Let’s begin!

1. What do you understand by PHP?

It stands for Hypertext Preprocessor and it’s a very popular server-side scripting language used for developing web applications. It is used with HTML coding for creating content, communication with the database server, etc.

2. What is the need for PHP?

Talking about the benefits of using PHP, there are many. The very first benefit is it’s free to use as anyone can use it without any cost. The second thing is it is compatible with multiple databases like MySQL that too is free to use. Also, the framework under PHP is very easy to use and therefore, makes the web development task quick and simple.

3. What do you understand by variable variables in PHP?

Sometimes, in PHP, when the value of a particular variable is used in the name of the other variable, then such a variable is known as variable variables. Below is the sample code:

$str = “PHP”;

$$str = ” Programming”; //declaring variable variables

echo “$str ${$str}”; //It will print “PHP programming”

echo “$PHP”; //It will print “Programming”

4. State the difference between echo and print?

Well, both the methods are used to print the output in the browser but there is a slight difference. Under the echo method doesn’t return any value after printing the output and the print method, on the other hand, returns the value after printing the output. Below is the sample code:

echo “PHP Developer”;

$n = print “Java Developer”;

5. State the way you can increase the maximum execution time of a script in PHP?

To increase the maximum execution time of a script, you just need to change the value of max_execution_time directive in the respective php.ini file.

For example: If you want to set the maximum execution time for 150 seconds, then you’ll set the value as:

max_execution_time = 150

6. State the way you can send an HTTP header to the ultimate client?

For this purpose, we use the header() function in order to send the raw HTTP header to the client. Below is the sample code:

header(‘Location: http://www.your_domain/’);

7. State the functions that are used to count the number of array elements?

There are two functions to count the total number of array elements in PHP namely, count() and sizeof(). Below is the sample code:


echo count($names);


echo sizeof($marks);

8. State the difference between substr() and strstr()?

substr() is the function that gives the part of the string which is based on the starting point and length. Below is the sample code:

echo substr(“Computer Programming”,9,7); //Returns “Program”

echo substr(“Computer Programming”,9); //Returns “Programming”

On the other hand, strstr() is the function that navigates and searches the very first occurrence of a string inside the other string thereof. Below is the sample code:

echo strstr(“Learning Laravel 5!”,”Laravel”); //Returns Laravel 5!

echo strstr(“Learning Laravel 5!”,”Laravel”,true); //Returns Learning

9. Explain, how can you upload a file using PHP?

There are three basic steps:

a. The first step is to enable the file_uploads directive by opening php.ini file and therefore, finding the directive and make it on.

file_uploads = On

b. The next step is to create an HTML form with the help of enctype attribute.
<form action=”upload.php” method=”post” enctype=”multipart/form-data”>

<input type=”file” name=”upd” id=”upd”>

<input type=”submit” value=”Upload” name=”upload”>


c. The last step is to write a PHP script for uploading the final file.

if (move_uploaded_file($_FILES[“upd”][“tmp_name”], “Uploads/”)) {

echo “The file “. basename( $_FILES[“upd”][“name”]). ” is uploaded.”;

} else {

echo “There is an error in uploading.”;


10. Which library is used in the context of PHP for various image work?

The library named as GD library can be used for various image works like rotating and cropping images, creating thumbnails etc.

Well, apart from these 10 questions we’ve dicussed today, there are several other questions too, that a candidate pursuing an interview for PHP job profile should go through to increase the chances of getting hired. Hope this article met your reading desires. Feel free to share your feedback. 


Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.