Posted by: phillipnb | June 19, 2012

Php Interview Questions


1).What is the output of the following?

$temp = false;
var_dump(isset($temp));

a).error b).true c).false d).0

2).$a=”; $b=2;

if (isset($a) && isset($b)) { echo “Yes”; } else { echo “No”; }

a).Yes b).No c). YesNo d).None

3).$a=”; $b=2; echo gettype($b);

a).Numeric b).String c).Char d).Integer

4).$c = 0; var_dump(is_bool($c));

a).true b).false c).null d).None

5).$d = 1;

if (is_bool($d) === true) { echo “Yes”; } else { echo “No”; }

a).Yes b).No c).None d).YesNo

6).$a = 100; $$a = 200; echo $a;

a).100 b).200 c).0 d).1

7).=== and == are the same?

a).true b).false c).error d).none

8).!= and !== are the same, if

a).boolean data type is used b).string data type is used c).objects are used d).None

9). The output of 3 * 3 % 4 and (3 * 3) % 4 is
a).4,4 b).0,4 c).4,0 d).0,0

10). What is the output of the following:
$a = 5;
echo ++$a + $a++;
a).7 b).6 c).10 d).12

11). Which of the following returns a string in which all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs?
a).chr() b).urlencode() c).unicode() d).utf_encode()

12). What is the correct syntax for setcookie()?
a).setcookie(name, expire, value, path, domain) b).setcookie(name, value, expire, domain, path)
c).setcookie(array, value, expire, path, domain) d).setcookie(name, value, expire, path, domain)

13).The session_start() function must appear
a).BEFORE the html tag b).AFTER the html tag
c).In the MIDDLE of the html page d).All of the above

14).Which of the following will reset your session?
a).session_destroy() b).session_start() c).session_default() d).session_cancel()

15).Sessions work by creating a unique id (UID) for each visitor. The UID is
a).either stored in a cookie or is propagated in the URL. b).stored as a cookie only
c).saved to the temp folder of the server only d).All of the above

16).In PHP, the session information is
a).Temporary b).Permanent c).based on settings in php_info file d).Based on client bandwidth

17).What does session_start() do?
a).register the user’s session with the server b).allow the user to start saving user information
c).assign a UID for that user’s session d).All of the above

18).Will lose all your stored session data if
a).session_start() is called b).session_destroy() is called c).session_cancel() is called d).None

19).Which of the following is true?
a).Session variables hold information about one single user and are available to all pages of an application.
b).Session variables hold information about multiples users and are available to all pages in all applications on that server.
c).Session variables hold information about one single user but are available to all pages in all application.
d).None of the above.

20).To clear a cookie
a).Set the cookie’s value to null b).Set the expiration date of the cookie to some time in the past c).Reset the cookie to zero d).All of the above

21). In the following script, what does the mode ‘r’ mean?
a).Read only. Starts at the beginning of the file
b).Read and Write. Starts at the beginning of the file
c).Write only. Opens and clears the file contents or creates a new file if it doesn’t exist
d).None of the above

22).If the fopen() function is unable to open a file, it returns
a). Zero or false b). True c).Null d).One (as string “1”)

23).feof() function is useful if the file is opened in which mode?
a). r b). w c). x d). a

24).Which function is used to read a single character from a file?
a).fgets() b).fread() c).fgets() d).fput()

25).In which of the following case does a file look funny when it is opened?
a).If the file is opened in “r+”mode
b).If you use the wrong line ending characters when writing your files
c).If proper mime type is not used when reading a file
d).None of the above


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.

Join 25 other followers

%d bloggers like this: