PHP Interview Questions & Answers for Freshers

Are you a looking for PHP Interview Questions for Freshers? Find PHP Interview Questions and Answers for beginners here. It is important to learn basic PHP concepts while doing PHP Job Preparation. These are the commonly asked Interview questions for beginners.

What is the use of in_array() function in PHP?

The in_array() function is used to search for the given string in an array. It returns TRUE if the given string is found in the array, and FALSE otherwise.


Which PHP function counts all the values of an array?

array_count_values() function is used to count all the values of an array. PHP array_count_values() returns an array that has the values of given array as keys and their frequency in the array as values.


What is the latest version of PHP?

The latest stable version of PHP is 7.3. As per the latest update, PHP 7.3.4 released at April 4, 2019.

For more detail about PHP version, visit official PHP website: php.net


What is the full form of PHP?

PHP originally stood for Personal Home Page, but it now stands for the recursive backronym PHP: Hypertext Preprocessor.


Which is the PHP function to delete a file from server?

PHP has lots of inbuilt Functions. One of them is the unlink() PHP function which is used to delete a file from server. Example: unlink("sample-file.php")


How can we create a session in php?

PHP session is a way to store information to be used across multiple pages. A session is started with the session_start() function. Session data is stored in the PHP global variable: $_SESSION.


Example to create a PHP SESSION


What is single line comment in PHP? Explain with syntax.

The single line comment tells the interpreter to ignore everything that occurs on that line to the right of the comment. To do a single line comment type // or # and all text to the right will be ignored by PHP interpreter.

Example of single line comment


What is the difference between == and === Operators in PHP?

PHP equal operator (==) and idential operator (===) are Relational or Comparison Operators in PHP langauge.

The only difference is that === operator matches the values along with Data types. While == operator only match values but not Data types.


Example to see difference between both operators

We have compared the two variable one by one by using == and === Operator, we get the following result.

You will see that value is matched if used the equal operator ‘==’ and not matched if used identical operator ‘===’ because data type is not same for both numbers.

Therefore, if we need to match both values strictly with datatypes, ‘===’ operator will be used else ‘==’ will be used in PHP.