Interview Questions


1.What is PHP?
PHP is a server side scripting language commonly used for web applications

2.How to include a file to a php page?
 we can include a file using "include() " or "require()" function with as its parameter..

3.What’s the difference between include and require?
If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.

4.require_once (), require (), include().What is difference between them?
require () includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page).
So, require_once () is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error.

5.How do you define a constant?
Using define() directive, like define ("MYCONSTANT",150)

6.What Is a Session?
It can be used to store information on the server for future use

7.How to set cookies in PHP?
Cookies are often used to track user information
Syntax:
Setcookie (name, value, expire, path, domain);
eg:Setcookie(“sample”, “ram”, time()+3600);

8.Difference between mysql_connect and mysql_pconnect?
There is a good page in the php manual on the subject, in short mysql_pconnect () makes a persistent connection to the database which means a SQL link that do not close when the execution of your script ends.

9.How to create a mysql connection?
mysql_connect (servername,username,password);

10.How to open a file?
    what is the use of mysql_fetch_array() function in php ?
This function returns a row from the table as an associative array or numeric array.
Write down the code for upload a file in php..
0) { echo “Error: ” . $_FILES["file"]["error"] . “
”; } else { echo “Upload: ” . $_FILES["file"]["name"] . “
”; echo “Type: ” . $_FILES["file"]["type"] . “
”; echo “Size: ” . ($_FILES["file"]["size"] / 1024) . ” Kb
”; echo “Stored in: ” . $_FILES["file"]["tmp_name"]; } ?>

11.what is the use of the function " explode() " in php?
This function is used to split a string by special character or symbol in the string, we must be pass the string and splitting character as parameter into the function.

12.What is use of in_array () function in php?
in _array used to checks if a value exists in an array


  1    2    3    4    5     6    7    8    9     10     11    12    13    14