PHP stands for hypertext preprocessor.It is widely used for web developement.

Find few questions and their answers which will be helpfull for development as well as interview preparation.

1) What is the full form of PHP ?

Ans: Hypertext Preprocessor


2) Differene between require and include ?

Ans: If a file is not found using require then it will throw a fatal error and execution will be halt. In case of include if the file is not found then system will throw a warning but execution will continue .


3) How do you denote a variable in PHP ?

Ans: $a=123;

where $a is the variable($ is used for variable denotion).


4) What is the use of substr ?

Ans: Suppose $str= “abcdef”; Now you want to print only abcde, what will you do ?

Just do this, substr($str, 0, -1);  // returns “abcde”

Look at below example for better understanding:

$str= substr(“abcdef”, 2, -1);  // returns “cde”
$str= substr(“abcdef”, 4, -4);  // returns “”
$str= substr(“abcdef”, -3, -1); // returns “de”

5) What is the use of trim function in PHP ?

Ans: Strip whitespace (or other characters) from the beginning and end of a string .

like suppose trim($string) where $string = ” abc”;

You can see above that $string has a value abc where there is a space before abc.So if you use trim($string),it will return only abc and will strip the whitespace.


6) What is the difference between print and echo ?

Ans: Both of them are language constructs which are used to display string .

We can use echo  for multiple parameters and echo is slightly faster than print.


7) How to  connect to MySql database using PHP ?

Ans: $link = mysql_connect(“mysql_hostname”,”mysql_username”,”mysql_password”);
$db = mysql_select_db(“dbname”,$link);

The default username of mysql used to be root on localhost.The default password of mysql used to blank on localhost.

Leave a Reply

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