PHP Interview Question and Answers

26. In how many ways we can retrieve data in the result set of MYSQL using PHP?
  mysql_fetch_array: - Fetch a result row as an associative array, a numeric array, or both.
mysql_fetch_assoc:- Fetch a result row as an associative array.
mysql_fetch_object:- Fetch a result row as an object.
mysql_fetch_row:- Get a result row as an enumerated array.
 
Your Name Your Email-ID
Your Answer
27. What are encryption functions in PHP?
  CRYPT(), MD5()
 
Your Name Your Email-ID
Your Answer
28. What is the functionality of the function htmlentities?
  htmlentities():- Convert all applicable characters to HTML entities This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.
 
Your Name Your Email-ID
Your Answer
29. How can we increase the execution time of a php script?
  By the use of void set_time_limit(int seconds) Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini. If seconds is set to zero, no time limit is imposed. When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out.
 
Your Name Your Email-ID
Your Answer
30. How to set cookies?
  setcookie('variable','value','time');
variable - name of the cookie variable
value - value of the cookie variable
time - expiry time
Example:
<?php
setcookie('Test',$i,time()+3600);
?>
Test - cookie variable name
$i - value of the variable 'Test'
time()+3600 - denotes that the cookie will expire after an one hour
 
Your Name Your Email-ID
Your Answer