Thursday 26 April 2012

PHP Interview question 1


1)What is PHP?
PHP (Hyper text Pre Processor) is a scripting language commonly used for web applications. PHP can be easily embedded in HTML. PHP generally runs on a web server. It is available for free and can be used across a variety of servers, operating systems and platforms.

2)What Is a Session in PHP?
A PHP session is no different from a normal session. It can be used to store information on the server for future use. However this storage is temporary and is flushed out when the site is closed. Sessions can start by first creating a session id (unique) for each user.
Syntax : session_start()
E.g. storing a customer’s information.

3)Explain the difference between $message and $$message.
$message is used to store variable data. $$message can be used to store variable of a variable. Data stored in $message is fixed while data stored in $$message can be changed dynamically.
E.g. $var1 = ‘Variable 1’
$$var1= ‘variable2’
This can be interpreted as $ Variable 1=‘variable2’;
For me to print value of both variables, I will write
$var1 $($var1)

4)What Is a Persistent Cookie?
Cookies are used to remember the users. Content of a Persistent cookie remains unchanged even when the browser is closed. ‘Remember me’ generally used for login is the best example for Persistent Cookie.

5)Explain the differences between require and include, include_once.
Include () will include the file specified.
Include_once () will include the file only once even if the code of the file has been included before.
Require () and include () are the same with respect to handling failures. However, require () results in a fatal error and does not allow the processing of the page.

No comments:

Post a Comment