1. What are the correct statements about Cookies in PHP ?

a)A cookie is often used to identify a user.
b)A cookie is a small file that the server embeds on the user’s computer.
c)Each time the same computer requests a page with a browser, it
will send the cookie too.
d)With PHP, you can both create and retrieve cookie values.

2.  A cookie is created with the ____________ function.


3.  setcookie(name, value, expire, path, domain, secure, httponly);

Only the name parameter is required. All other parameters are optional.
Is this statement correct?


4. What are the correct statements ?

a) The setcookie() function must appear BEFORE the <html> tag.
b) The value of the cookie is automatically URLencoded when sending the          cookie, and automatically decoded when received
c) If want To modify a cookie, just set the cookie using the
setcookie() function.
d) To delete a cookie, use the setcookie() function with an expiration date in      the past.

5. The………………….function returns a string with backslashes in

front of the specified characters. 

a) Addcslashes()
b) addcslashes()
c) add_slash()
d) add_backslash()

6. Select the correct statement(s)

a) addcslashes() function returns a string with backslashes in front of the       specified characters.
b) addcslashes() function is not case sensitive.
$str = addcslashes(“Hello World!”,”W”);
output of this code is     Hello \World!

d) It returns the escaped string.

7. What are the correct statements about superglobals?

a) “superglobals” are always accessible, regardless of scope and we can
access them from any function, class or file without doing anything
b) $_SESSION , $_COOKIE, $_ENV, $_FILES are the superglobal variables.
c) $GLOBALS is a PHP super global variable which is used to access global
variables from anywhere in the PHP script.
d) $_POST is not a superglobal veriable. It is used to collect form data after
submitting an HTML form with method=”post”.

8. Which of the following among A,B and C can be used to include comments in PHP?

A:   /* */
B: #
C: //

a) A and B only     b) A and C only    c) B and C only   d) All A,B and C

9. What is/are the correct statement(s)? about variables.

a) A variable name cannot start with a number.
b) A variable name can only contain alpha-numeric characters and
underscores (A-z, 0-9, and _ ).
c) Variable names are case-sensitive ($age and $AGE are two different
d) A variable name must start with a letter or the underscore character.
e) A variable starts with the $ sign, followed by the name of the variable.


10. PHP is __________ scripting language.

a) sever-side
b) client-side
c) Middle-side
d) out-side  🙂

11. PHP scripts are executed on _________.

a) Client compuer
b) Server computer
c) Depends on PHP code
d) None

12. Which of the following delimiting method is known as

a) delimitted by single quotes.
b) delimitted by <<< identifier.
c) delimitted by single quotes.
d) All of above.

13. In PHP, which datatypes are treaded as arrays.

a) string
b) integer
c) float
d) booleans

14. What is the output of fllowing script would be.

function ad it () {
GLOBAL $var;
$var++ ;
echo “value is $var”;
addit ();

a) value is 15
b) value is $var
c) value is 1
d) value is 16

16. Variable scope on which a variable does not loose its value when the
       function exists and use that value if the function is called again is.

a) local
b) static
c) function parameter
d) none of above

17. The left association operator % is used in PHP for

a) percentage
b) division
c) bitwise AND
d) modulus

18. Which of the following functions require the allow-url-fopen must

a) include()
b) require()
c) both (a) and (b)
d) None

19. On failure of which statement the script execution stops displaying
       error/warning message?

a) include()
b) require()
c) both (a) and (b)
d) None of above

20. Trace the false statement

a)  Any code found within an included file will inherit the variable scope of
the location of its caller

b)  Because the included code will be embedded in a PHP execution block,
the PHP execution block, the PHP escape tags (<?php?>  aren’t
required on the file to be included.

c)  For the inclusion of remote files the allow-url-pope must be enabled ad
URL wrapper must be supported

d)  Including a file produces the same result as copying the data from the
file specified into the location in which thestatement appears.

21. correct statements?

a) str_replace() function replaces some characters with some other
characters in a string.
b) str_replace() function is case-sensitive.
c) str_ireplace() function use to perform a case-insensitive search.
d) syntax of this function is str_replace(find,replace,string,count). (count is
a variable that counts the number of replacements)




1.Answer; All(a,b,c,d).
2.Answer; a.
3.Answer; a.
4.Answer; All.
5.Answer; b.
6.Answer; a,c,d
7.Answer; a,b,c
8.Answer; d.
9.Answer; a,b,c,d,e.
10.Answer; a.
11.Answer; b.
12.Answer; b.
13.Answer; a.
14.Answer; d.
16.Answer; b.
17.Answer; d.
18. Answer; c.
19. Answer; b.
20. Answer; b.
21. Answer; a,b,c,d.



5 thoughts on “PHP Qs

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s