Thursday, 26 April 2012

PHP Interview question 3


11)How to set cookies in PHP?
Cookies are often used to track user information.
Cookies can be set in PHP using the setcookie() function.
Parameters are : name of the cookie, Value of cookie, time for expiry of cookie, path of the cookies location on server, domain, secure (TRUE or FALSE) indication whether the cookie is passed over a secure HTTPS, http only (TRUE) which will make the cookie accessible only through HTTP.
Returns TRUE or FALSE depending on whether the cookie was executed or not.

12)What is Type juggle in php?
Type Juggling means dealing with a variable type. In PHP a variables type is determined by the context in which it is used. If an integer value is assigned to a variable, it becomes an integer.
E.g. $var3= $var1 + $var2
Here, if $var1 is an integer. $var2 and $var3 will also be treated as integers.  

13)Explain the difference between include and require.
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. i.e. include will allow the script to continue.



No comments:

Post a Comment