PHP Interview Questions for Freshers

PHP Interview Questions for Freshers

Whether the popularity as a scripting language or demand as a feature full filled website development platform; PHP has become a major player in the web development market in the last few years.Day by day,increasing demand for PHP has brought us countless development opportunities for freshers as well as experienced candidates. We are going to discuss the most asked PHP interview questions for freshers with their suggested answers further here. Importantly, these questions mentioned here will be different from the traditional ones, which is again most preferred by the employers nowadays for selection of the right candidate.

Let’s discuss them out now.

  1. How can JavaScript and PHP interact?

These two can’t interact directly since JavaScript is a client-side language,but PHP is a server side language. However, developers can exchange variables in between these two as PHP is able to generate JavaScript code which can be executed by the browser, so it’s possible to pass specific variables via URL back to the PHP.

Where is the example? I have already mentioned this in the last email.

  1. What is basic difference between mysqli_fetch_array() and mysqli_fetch_object()?

In PHP, the mysqli_fetch_array()function bathers matching records available in a table in an array, whereas the mysqli_fetch_object() function offers users only the first single matching record from the table.

For more PHP interview questions for freshers, please click here.

  1. How to access data sent through URL with a GET method?

We, PHP developers,use the$_GET array to access data sent through an URL with a GET method. The following syntax will be used:

$variable = $_GET[“var”]; this will now contain ‘value’



  1. What are the differences between implode and explode in PHP?
·         The function Implode() is used by PHP developers to join elements of an array with a string.

·         Syntax

·         We canuse the Explode() function to split a string by a specified string into different pieces.

·         Syntax


  1. How to make constants in PHP?

We can make constants in PHP by using the define() function. The function accepts two arguments,which are –the name of the constant and its value. Once we define a constant, the value of the constant can be accessed by just referring its name any time. The syntax to create a constant will be as follows.

bool define(identifier, value, case-insensitivity)



  1. What are the difference between array_merge() and array_combine()?
·         The array_merge() function is used by developers to merge the elements of one or multiple arrays such that the value presented by one array appended at the end of the first array.·         We use the array_combine()function for creating a new array by using the one array key as keys and other array value as values.


  1. What are the types of errors in PHP?

There is four main types of errors in PHP as follows.

Fatal Error–In this error, the PHP compiler understands the PHP code used but it also identifies an undeclared function. This means where the function will be called without its proper definition of the function.




function add($x, $y)


            $sum = $x + $y;

            echo “sum = ” . $sum;


$x = 0;

$y = 20;

add($x, $y);


diff($x, $y);



Parse Error –Also known as the syntax error; it occurs when there is a syntax error present in the script. This error stops the script execution. Few common reasons for this error occurrence are extra or missing parentheses, un closed braces or quotes, and missing semicolon.



echo “Cat”;

echo “Dog”

echo “Lion”;



Notice Error–This error shows when the execution of the script doesn’t stop. When we try to access the undefined variable, the Notice Error will appear.




echo “Notice Error !!”;

echo $b;



Warning Errors–A missing file and use of incorrect parameters in a function can cause warning error. It will not stop the script execution.



echo “Warning Error!!”;

include (“Welcome.php”);



  1. What is the difference between print and echo in PHP?
·         The statement echo can be used both with and without the parentheses, i.e.,echo or echo() to display the output.

·         Multiple string pass is allowed here using ( , ).
·         It doesn’t return any value.

·         Faster operates compared to the Echo.

·         The print statement is used to display the output with or without parentheses print.

·         Print is unable to pass multiple arguments.
·         It always returns 1.

·         It operates slower compared to echo.


  1. What the difference is between include and requires in PHP?
·         The function include() has a specific file that enables a warning if it is unable to be found and execute the remaining scripts.

·         It should be executed when the file is not necessarily required,and application flow should be continuing without it.

·         Syntax
include ‘filename’;


·         The require() function also includes a specified file but if only the file has already been included.

·         It will present a fatal error if the file is not present and stops the application execution.

·         Syntax
require ‘filename’;


  1. What is the difference between session and cookie?
·         This one is a collection of data stored on a server according to a user and ID code it contains.

·         When the user closes the browser or leaves a website, a session ends.
·         Can store an unlimited amount of data.
·         More secure compared to cookies.

·         It’ ssmall data as a text file format stored in the browser and delivered near the server with every request.

·         The browser sends cookies information to the server and server uses that information for user identification.

·         Capable only to store a limited amount of data.

·         It is less secure.


Best Interview Questions portal presents you the most interviewers asked PHP interview questions with their suggested answers for your practice, ensuring guaranteed results for future aspirants. Don’t forget to check today.

Leave a Reply

Your email address will not be published. Required fields are marked *