PHP Multiple Choice Questions and Answers: Ans: D and e
PHP Multiple Choice Questions and Answers: Ans: D and e
13) If visibility is not defined for a method/member then it is treated as public static
a. True
b. False
Ans: b
18) Which of the following attribute is needed for file upload via form?
a. enctype='multipart/form-data'
b. enctype='singlepart/data'
c. enctype='file'
d. enctype='form-data/file'
Ans: a
20) The inbuilt function to get the number of parameters passed is:
a. arg_num()
b. func_args_count()
c. func_num_args()
d. None of the above
Ans: c
35) Which of the following variable declarations within a class is invalid in PHP5?
a. private $type = 'moderate';
b. internal $term= 3;
c. public $amnt = '500';
d. protected $name = 'Quantas Private Limited';
Ans: b
36) Which of the following is used to maintain the value of a variable over different pages?
a. static
b. global
c. session_register
d. None of the above
Ans: c
39) Which of the following regular expressions can be used to check the validity of an e-
mail addresses?
a. ^[^@ ]+@[^@ ]+.[^@ ]+$
b. ^[^@ ]+@[^@ ]+.[^@ ]+$
c. $[^@ ]+@[^@ ]+.[^@ ]+^
d. $[^@ ]+@[^@ ]+.[^@ ]+^
Ans: b
40) You wrote the following script to check of the right category:
Correct category!
Incorrect category!
What will be the output of the program if value of 'cate' remains 5?
a. Correct category!
b. Incorrect category!
c. Error due to use of invalid operator in line 6:'if ($cate==5)'
d. Error due to incorrect syntax at line 8, 10, 12 and 14
Ans: a
41) You are using sessions and session_register() to register objects. These objects are
serialized automatically at the end of each PHP page and are de-serialized automatically on
each of the following pages. Is this true or false?
a. True
b. False
Ans: a
44) In your PHP application you need to open a file. You want the application to issue a
warning and continue execution, in case the file is not found. The ideal function to be used
is:
a. include()
b. require()
c. nowarn()
d. getFile(false)
Ans: a
46) You need to count the number of parameters given in the URL by a POST operation.
The correct way is:
a. count($POST_VARS);
b. count($POST_VARS_PARAM);
c. count($_POST);
d. count($HTTP_POST_PARAM);
Ans: c
47) Which of the following is correct with regard to echo and print?
a. echo is a construct and print is a function
b. echo is a function and print is a construct
c. Both are functions
d. Both are constructs
Ans: d
52) You have defined three variables $to, $subject and $body to send an email. Which of the
following methods would you use for sending an email?
a. mail($to,$subject,$body)
b. sendmail($to,$subject,$body)
c. mail(to,subject,body)
d. sendmail(to,subject,body)
Ans: a