PHP Interview Questions And Answers – II
1. Which of the following functions allows you to store session data in a database?
D. You cannot store session data in a database.
You can use session_set_save_handler() to override PHP’s default session-handling functions and store session data any way you want.
3. What is the difference between $variable and $$variable?
$variable = “me”;
$me = “PHP”;
echo $variable; // Output: meecho
$$variable; // Output: PHP
4. What is the function used to get the ASCII value of the character?
5. What is the use of ===?
=== will compare both the value of the variable and its datatype
6. What is the Diff. Between echo() and Print() in PHP?
Echo is used to display multiple arguments Whereas Print is used to display only one argumet
7. How do you connet mysql database with PHP ?
$link = mysqli_connect(“localhost”, “username”, “password”, “dbofpcds”);
$mysqli = new mysqli(“localhost”, “username”, “password”, “dbname”);
In old type of connectivity were
$link = mysql_connect(“localhost”, “username”, “password”);
8. In how many ways we can retrieve the data in the result set of MySQL using PHP?
1. mysqli_fetch_row –> Get a result row as an enumerated array
2. mysqli_fetch_array –> Fetch a result row as associative and numeric array
3.mysqli_fetch_object –> Returns the current row of a result set as an object
4. mysqli_fetch_assoc –> Fetch a result row as an associative array
9. What does a special set of tags <?= and ?> do in PHP?
The output is displayed directly to the browser.
10. How to find out the number of parameters passed into function?
By using the function func_num_args() which returns the number of parameters passed