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?
Rasmus Lerdorf
Q2: What is the difference between $user and $$user?
$user is variable and $$user is reference variable
like
$user=kannan
and
$$user=saran
so $kannan value is saran.
Q3: What is the difference between GET and POST method?
GET | POST |
|
|
Q4: How can we extract string “mytypings.co.in ” from a string “http://info@mytypings.co.in using a regular expression of PHP?
preg_match(“/^http:\/\/.+@(.+)$/”,”http://info@mytypings.co.in”,$checks);
echo $checks[1];
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?
encryption | decryption |
AES_ENCRYT() | AES_DECRYPT() |
ENCODE() | DECODE() |
DES_ENCRYPT() | DES_DECRYPT() |
ENCRYPT() | Not available |
MD5() | Not available |
OLD_PASSWORD() | Not available |
PASSWORD()> | Not available |
SHA() or SHA1() | Not available |
Not available | UNCOMPRESSED_LENGTH() |
Q12: What are the different types of errors in PHP?
- Notice
- Warning
- Fatal
Q13: What is the difference between strstr and stristr?
strstr function
Returns part of a string from the first occurrence to the end of the string.
$mail= ‘test@mytypings.com’;
$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”);
Comments-
(March 30, 2023 - 7:13 pm)
-
(March 31, 2023 - 11:42 am)
CraigNek
Good Collection of Q&A…
StephenMon
Thanks for the blog.