PHP Interview Question and Answers

6. What is a Session?
  A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests. Sessions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor.
 
Pankaj, said Apr 23,2014
Session is used to store temporary data, after unset the session session data destroy from web page.
Your Name Your Email-ID
Your Answer
7. How can we register the variables into a session?
  <?php
session_register($ur_session_var);
?>
 
Your Name Your Email-ID
Your Answer
8. How do you destroy a particular or all Sessions?
  <?php
session_start();
// store session data
$_SESSION['views']=1;
unset($_SESSION['views']); // If you wish to delete some session data, you can use the unset()
session_destroy(); // You can also completely destroy the session by calling the session_destroy() function. session_destroy() will reset your session and you will lose all your stored session data.
?>
 
Your Name Your Email-ID
Your Answer
9. How many ways we can pass the variable through the navigation between the pages?
 
  • Register the variable into the session
  • Pass the variable as a cookie
  • Pass the variable as part of the URL
 
Your Name Your Email-ID
Your Answer
10. What are the different functions in sorting an array?
 
  • asort()
  • arsort()
  • ksort()
  • krsort()
  • uksort()
  • sort()
  • natsort()
  • rsort()
 
Your Name Your Email-ID
Your Answer