Breaking News
Loading...
Monday 30 July 2012

PHP Interview Question and Answers

04:37
21. What is the difference between the functions unlink and unset?

unlink() deletes the given file from the file system.
unset() makes a variable undefined.

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

eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching
alphabetic characters.

23. What is the difference between characters \023 and \x23?

The first one is octal 23, the second is hex 23.

24. What is the difference between PHP4 and PHP5?

PHP4 cannot support oops concepts and Zend engine 1 is used.

PHP5 supports oops concepts and Zend engine 2 is used. Error supporting is increased in PHP5. XML and SQLLite will is increased in PHP5.

25. What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?

mysql_fetch_array:
Fetch a result row as an associative array and a numeric array.

mysql_fetch_object:
Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. Returns an object with properties that correspond to the fetched row, or FALSE if

there are no more rows.

mysql_fetch_row():
Fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

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.

27. What are encryption functions in PHP?

CRYPT(), MD5()

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.

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.

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:
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.

<< Next 1 2 3 4 5 Previous>>

Share This :
Tags:

0 comments:

Post a Comment

 
Toggle Footer