Dear readers this article will give you a basic idea of the PHP programing language interview. We have discussed the basic and frequently asked questions with precise and short answers.
After going through these questions you will be ready for an interview but I would recommend going through these questions and function mentioned in this article in a bit depth.
Let’s get started:
Q1: Who is the father of PHP?
Q2: What is the difference between $user and $$user?
$user is variable and $$user is reference variable
so $kannan value is saran.
Q3: What is the difference between GET and POST method?
Q4: How can we extract string “mytypings.co.in ” from a string “http://firstname.lastname@example.org using a regular expression of PHP?
Q5: What is the differences between require and include?
Require function is same as include, except that it handles errors in a different way,
If an error occurs while using the include method, it will generate a warning but the script will continue. Which means rest code will work however
if an error occurs while using the require method, it will generate a fatal error which will stop script execution.
Q6: Is it possible to include (“abc.PHP”) two times in a PHP page?
Yes, It is possible. But it will create some problems like if there are some functions declared in the abc.php file and we are including the same file (abc.php) multiple times, it will result in function redeclaration error. Otherwise, there will be no issue in including a file twice in a PHP page.
Q7: What is use of header() function in php ?
We can use header() function for page redirection. It is important to notice that header() must be called before any actual output is shown.
Q8: How to execute a PHP script using the command line?
PHP CLI (Command Line Interface) will make this process possible for us.
EX: php sample.php
Q9: What is nl2br()?
It inserts HTML line breaks (<BR />) before all newlines in a string.
Q10: How do we get the IP address of a client and previous page reference?
By using $_SERVER[‘REMOTE_ADDR’],$_SERVER[‘HTTP_REFERER’]
Q11: How do we encrypt and decrypt in PHP?
|SHA() or SHA1()||Not available|
Q12: What are the different types of errors in PHP?
Q13: What is the difference between strstr and stristr?
Returns part of a string from the first occurrence to the end of the string.
$domain = strstr($mail, ‘@’);
echo $domain; // prints @mytypings.com
stristr function is case-insensitive. It considers `b` and `B` as same.
Q14: What is the purpose of the function htmlentities?
It converts all applicable characters to HTML entities.
Q15: How do we get second using date function?
$second = date(“s”);