Top 10 PHP Interview Questions And Answers

Nov 11, 2019 Eduardo Zambrano

Who is the father of PHP?

Rasmus Lerdorf

How can we encrypt and decrypt a username and password using PHP?

The function below performs encryption and decryption,

Encryption Decryption
OLD_PASSWORD() Not available
ENCRYPT() Not available
MD5() Not available
SHA() or SHA1() Not available
PASSWORD() Not available

What is the difference between $message and $$message?

$message is a variable. Whereas $$message is a reference variable. Suppose $message="test"; $$message is $test.

What are the differences between GET and POST methods?

GET and POST methods are used to transfer data from one page to another. But the way of transfer is different. GET Method to have a limit like only 2kb data able to send for request. But in the POST method, unlimited data can be sent.

When we use GET method, the requested URL show in the URL. Whereas, Not in the POST method. The POST method is good for sending sensitive data.

What is the use of header() function PHP?

header() function is used for the redirection of pages. It is very important that the header must be called before any actual output screen is seen.

How we get IP addresses and previous references of clients using PHP?


What are the different types of errors in PHP?

  1. Warnings: Suppose if you are including a file, but the file does not exist. It will produce a warning error. But it will not terminate the script. By default, these errors are displayed to the user.
  2. Fatal Error: Suppose if you are including a file using require() function, It will produce a fatal error. But it is a critical error and it will terminate the flow of the script.

What is the functionality of the function strstr and stristr?

strstr returns the subpart of the string that we are finding out to the end of the string.

echo $domain_address; //Returns

stristr is case insensitive. It cannot able to differentiate between a and A

How can we get the current date and time using PHP?

      <?php echo date('Y-m-d H:i:s'); ?>

What is the difference between the functions unset and unlink?

unset makes a variable undefined., Whereas unlink deletes the file from the file system.

How can we get browser properties using PHP?

By using, $_SERVER['HTTP_USER_AGENT'] variable.
What is the difference between session_unregister and session_unset?