PHP Interview Questions And Answers – II

1. Which of the following functions allows you to store session data in a database?
A. session_start();
B. session_set_save_handler();
C. mysql_query();
D. You cannot store session data in a database.
Answer: B
You can use session_set_save_handler() to override PHP’s default session-handling functions and store session data any way you want.

2. How can you insert JavaScript in PHP code?
echo ‘<script type=”text/javascript”>YOUR JS HERE</script>’;

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


You may also like

1 Comment

  • JonesRay
    January 8, 2017 at 3:46 PM

    Thanks for the useful interview questions, it helps me a lot to learn the subject and gave a lot of confidence to face interviews easily


Welcome To TechTwinklers!

Tech Twinklers is a Tech Blog run by Students with an aspiring enthusiasm in Technology and Gaming. This Blog will bring News about the Modern Technology, Educational Advances, Campus Interviews, etc. So make sure you subscribe to our blog because we don't want you to miss a thing that is posted here..

We're on Facebook!