Saturday 28 April 2012

PHP Interview question 12


41) How can we optimize or increase the speed of a MySQL select query?
Ans:  first of all instead of using select * from table1, use select  column1, column2, column3.. from table1 Look for the opportunity to introduce index in the table you are querying. use limit keyword if you are looking for any specific number of rows from the result set.

42) How many ways can we get the value of current session id?
Ans :      session_id() returns the session id for the current session.

43) How can we destroy the session, how can we unset the variable of a session?
Ans :  session_unregister  Unregister a global variable from the current Session session_unset Free all session variables

44) How can we set and destroy the cookie n php?
Ans :      By using setcookie(name, value, expire, path, domain); function we can set the cookie in php ;
Set the cookies in past for destroy. Like setcookie("user", "sonia", time()+3600); for set the cookie
setcookie("user", "", time()-3600); for destroy or delete the cookies;      

45) How many ways we can pass the variable through the navigation between the pages?
Ans : GET/QueryString
    POST                 

No comments:

Post a Comment