Saturday, May 7, 2011

PHP INTERVIEW QUESTIONS 40-50

41. How can we optimize or increase the speed of a mysql select query?


For increase speed of select query, there are some factor  like...
1. By using Limit in query
2. By using Index on table

3. By using Primary key

42. How many ways can we get the value of current session id?



We can get the value of current session with the use of session_id() returns the session id for

the current session.Apart from session_id, we can retrieve it using SID constant in PHP6.


43. How can we destroy the cookie?

set the cookie in the past setcookie("name","value",time()-3600); 

44. How can we destroy the session, how can we unset the variable of a session?

session_destroy() - destroys all data registered to current session 
unset($_session['name']) - destroy varible specified with session


45. How many ways we can pass the variable through the navigation between the pages?
  1. Put the variable into session in the first page, and get it back from session in the next page.

  2. Put the variable into cookie in the first page, and get it back from the cookie in the next page.

  1. Put the variable into a hidden form field, and get it back from the form in the next page.

  2. Using post

  1. Using get

  2. Using request


46. What is the difference between ereg_replace() and eregi_replace()?


ereg_replace() is case sensitive like “test” cannot be treated as “TeSt” and

eregi_replace() is not case sensitive that means insensitive where “test” could be treated as “TeSt”.


47. What are the different functions in sorting an array?

Asort() arsort() ksort() krsort() uksort() sort() natsort() rsort()


48. How can we know the count/number of elements of an array?

count(array) function returns the total number of elements of specified array. 

49. What is the PHP predefined variable that tells the What types of images that PHP supports?

int imagetypes ( void ) This function returns a bit-field corresponding to the image formats
supported by the version of GD linked into PHP. The following bits are returned,
IMG_GIF | IMG_JPG | IMG_PNG |IMG_WBMP | IMG_XPM.

50. How can I know that a variable is a number or not, using a JavaScript?

isNaN(value)




No comments:

Post a Comment