Sunteți pe pagina 1din 17

55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.

30 PM

REAL TIME Interview Questions


TOP Interview Questions Answers

Home

55 TOP PHP MULTIPLE


CHOICE QUESTIONS AND
ANSWERS PDF
Posted on March 31, 2017 by Real Time Interview
Questions Comments O!

1) Which of the following are not considered as Boolean


false?
a. FALSE
b. 0
c. “0”
d. “FALSE”
e. 1
f. NULL
Ans: d and e

2) Consider the following class:


Class Insurance
{
function clsName()
{
echo get_class($this);
}

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 1 of 17
55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.30 PM

}
8. $cl = new Insurance();
9. $cl -> clsName();
10. Insurance::clsName();
Which of the following Lines should be commented to print
the class name without errors?
a. Line 8 and 9
b. Line 10
c. Line 9 and 10
d. All the three lines 8,9, and 10 should be left as it is.
Ans: d

3) Variables/functions in PHP don’t work directly with:


a. echo()
b. isset()
c. print()
d. All of the above
Ans: b

PHP Multiple choice Questions

4) What is the output of the following code?


a. Array ([x]=>9 [y]=>3 [z]=>-7)
b. Array ([x]=>3 [y]=>2 [z]=>5)
c. Array ([x]=>12 [y]=>5 [z]=>-2)
d. Error
e. None of the above
Ans: c

5) Which of the following multithreaded servers allow PHP as


a plug-in?

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 2 of 17
55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.30 PM

a. Netscape FastTrack
b. Microsoft’s Internet Information Server
c. O’Reilly’s WebSite Pro
d. All of the above
Ans: d

6) Which of the following statements is incorrect with regard


to interfaces?
a. A class can implement multiple interfaces
b. An abstract class cannot implement multiple interfaces
c. An interface can extend multiple interfaces
d. Methods with same name, arguments and sequences can
exist in the di!erent interfaces implmented by a class
Ans: d

7) Which of the following type cast is not correct?


a. real
b. double
c. decimal
d. boolean
Ans: c

8) What will be the output of the following code?


$var = 10;
function fn ()
{
$var = 20;
return $var;
}
fn ();
echo $var;
a. 10
b. 20
c. Unde"ned Variable
d. Syntax Error
Ans: a

9) which of the following are the valid PHP data types?

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 3 of 17
55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.30 PM

a. resource
b. null
c. boolean
d. string
e. Both a and c
f. Both b, c and d
g. All of the above
Ans: g

10) which of the following characters are taken care of by


htmlspecialchars?
a. < b. >
c. single quote
d. double quote
e. &
f. All of the above
Ans: f

11) What do you infer from the following code?


a. Only "rst character will be recognised and new line will be
inserted.
b. Last will not be recognised and only "rst two parts will
come in new lines.
c. All the will work and text will be printed on respective new
lines.
d. All will be printed on one line irrespective of the
Ans: d

12) which of the following is a correct declaration?


a. static $varb = array(1,’val’,3);
b. static $varb = 1+(2*90);
c. static $varb = sqrt(81);
d. static $varb = new Object;
Ans: a

13) If visibility is not de"ned for a method/member then it is


treated as public static
a. True

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 4 of 17
55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.30 PM

b. False
Ans: b

14) what is true regarding $a + $b where both of them are


arrays?
a. Duplicated keys are NOT overwritten
b. $b is appended to $a
c. The + operator is overloaded
d. This produces a syntax error
Ans: a,b

15) Which of the following is Ternary Operator?


a. &
b. =
c.
d. ?:
e. +=
f. &&
Ans: d

16) Which of the following vairables are supported by


‘str_replace()’ function?
a. Integer
b. String
c. Boolean
d. Array
Ans: b,d

17) which of the following pair have non-associative equal


precedence?
a. +,-
b. ==, !=
c.
d. &=, |=
Ans: b

18) Which of the following attribute is needed for "le upload


via form?

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 5 of 17
55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.30 PM

a. enctype=’multipart/form-data’
b. enctype=’singlepart/data’
c. enctype=’"le’
d. enctype=’form-data/"le’
Ans: a

19) Which of the following functions output text?


a. echo()
b. print()
c. println()
d. display()
Ans: a,b

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

21) Consider the following two statements:


I while (expr) statement
II while (expr): statement… endwhile;
Which of the following are true in context of the given
statements?
a. I is correct and II is wrong
b. I is wrong and II is correct
c. Both I & II are wrong
d. Both I & II are correct
Ans: d

22) Multiple select/load is possible with:


a. Checkbox
b. Select
c. File
d. All of the above
Ans: b

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 6 of 17
55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.30 PM

23) Which of the following statement is not correct for PHP?


a. It is a server side scripting language
b. A PHP "le may contain text, html tags or scripts
c. It can run on windows and Linux systems only
d. It is compatible with most of the common servers used
today
Ans: c

24) Which of the following printing construct/function


accpets multiple parameters?
a. echo
b. print
c. printf
d. All of the above
Ans: a

25) Does PHP provide the goto keyword in latest version?


a. Yes
b. No
Ans: b

26) We have two variable de"nitions:


1. 023
b. x23
Choose the correct options:
a. 1 is octal
b. 2 is hexadecimal
c. 2 is octal
d. 1 is hexadecimal
Ans: a,b

27) Which of the following is not a prede"ned constant?


a. TRUE
b. FALSE
c. NULL
d. _FILE_
e. CONSTANT
Ans: d

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 7 of 17
55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.30 PM

28) What will be the output of the following code?


$a = 10;
if ($a > 5 OR < 15)
echo ‘true’;
else
echo ‘false’;
a. true
b. false
c. No output
d. Parse Error
Ans: d

29) You need to check the size of a "le in PHP function.


$size = X("lename);
Which function will suitably replace ‘X’?
a. "lesize
b. size
c. sizeofFile
d. getSize
Ans: a

30) Which of the following vaiables is not related to "le


uploads?
a. max_"le_size
b. max_execution_time
c. post_max_size
d. max_input_time
Ans: d

31) Which of the following variable names are invalid?


a. $var_1
b. $var1
c. $var-1
d. $var/1
e. $v1
Ans: c,d

32) What will be the output of the following code?

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 8 of 17
55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.30 PM

function fn (&$var)
{
$var = $var – ($var/10*5);
return $var;
}
echo fn(100);
a. 100
b. 50
c. 98
d. Error message
e. None of the above
Ans: d

33) What will be the output of following code?


$a = 10;
echo ‘Value of a = $a’;
a. Value of a = 10
b. Value of a = $a
c. Unde"ned
d. Syntax Error
Ans: a

34) What will be the output of the following code?


$Rent = 250;
function Expenses($Other)
{
$Rent = 250 + $Other;
return $Rent;
}
Expenses(50);
echo $Rent;
a. 300
b. 250
c. 200
d. Program will not compile
Ans: b

35) Which of the following variable declarations within a

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 9 of 17
55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.30 PM

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 di!erent pages?
a. static
b. global
c. session_register
d. None of the above
Ans: c

37) How would you store order number (34) in an


‘OrderCookie’?
a. setcookie(‘OrderCookie’,34);
b. makeCookie(‘OrderCookie’,34);
c. Cookie(‘OrderCookie’,34);
d. OrderCookie(34);
Ans: a

38) The following php variables are declared:


$company = ‘ABS Ltd’;
$$company = ‘,Sydney’;
Which of the following is not a correct way of printing ‘ABS
Ltd,Sydney’?
a. echo ‘$company $$company’;
b. echo ‘$company ${$company}’;
c. echo ‘$company ${‘ABS Ltd’}’;
d. echo ‘$company {$$company}’;
Ans: a

39) Which of the following regular expressions can be used


to check the validity of an e-mail addresses?
a. ^[^@ ]+@[^@ ]+.[^@ ]+$
b. ^[^@ ]+@[^@ ]+.[^@ ]+$

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 10 of 17
55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.30 PM

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

42) Which of the following is not supported in PHP5?


a. Type Hinting
b. Re#ection
c. Magic Methods
d. Multiple Inheritance
e. Object Cloning
Ans: d

43) What will be the output of the following code?


echo 30*5 . 7;
a. 150.7
b. 1507
c. 150.7

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 11 of 17
55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.30 PM

d. you can’t concatenate integers


e. error will occur
Ans: b

44) In your PHP application you need to open a "le. You want
the application to issue a warning and continue execution, in
case the "le is not found. The ideal function to be used is:
a. include()
b. require()
c. nowarn()
d. getFile(false)
Ans: a

45) What will be the output of the following code?


a. int(3*4)
b. int(12)
c. 3*4
d. 12
e. None of the above
Ans: b

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

48) Which of the following functions output text?

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 12 of 17
55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.30 PM

a. echo()
b. print()
c. println()
d. display()
Ans: a,b

49) How would you start a session?


a. session(start);
b. session();
c. session_start();
d. begin_session();
Ans: c

50) What will be the output of following code?


$a = 10;
echo ‘Value of a = $a’;
a. Value of a = 10
b. Value of a = $a
c. Unde"ned
d. Syntax Error
Ans: a

51) Which of the following is not true regarding XForms?


a. PHP provides support for XForm
b. It can be used on PDF documents
c. The data is sent in XML format
d. The action and method parameters are de"ned in the
body
Ans: d

52) You have de"ned 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

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 13 of 17
55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.30 PM

53) Which of the following are useful for method


overloading?
a. __call, __get, __set
b. _get,_set,_load
c. __get,__set,__load
d. __overload
Ans: a

54) Which of the following is a PHP resource?


a. Domxml document
b. Odbc link
c. File
d. All of the above
Ans: d

55) Does PHP 5 support exceptions?


a. Yes
b. No
Ans: a

Posted in PHP Multiple choice Questions Tagged core php


multiple choice questions and answers, multiple choice
questions based on php, multiple choice questions in php
mysql, PHP Certi"cation Questions, PHP MCQs, php multiple
choice questions and answers code, php multiple choice
questions and answers for freshers, php multiple choice
questions and answers pdf, php multiple choice questions
and answers script, php mysql multiple choice questions,
PHP Objective type Questions, PHP Online Quiz Questions,
php oops multiple choice questions, php programming
multiple choice questions and answers

← 105 TOP PHP INTERVIEW 35 TOP MySQL MULTIPLE


QUESTIONS AND ANSWERS CHOICE QUESTIONS PDF →
PDF

REAL TIME Interview

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 14 of 17
55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.30 PM

Questions > PHP Multiple


choice Questions > 55
TOP PHP MULTIPLE
CHOICE QUESTIONS AND
ANSWERS PDF

Categories
Select Category

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 15 of 17
55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.30 PM

Recent Posts
25+ React js Interview
Questions Answers pdf

50 TOP ANGULAR 4
INTERVIEW QUESTIONS
AND ANSWERS

TOP 50 HVAC Interview


Questions & Answers pdf
download

25 TOP Angular 2
Interview Questions and
Answers pdf

22 TOP Robotic Process


Automation (RPA)
Interview Questions and
Answers pdf

20 [TOP] RPA Blue Prism


Interview Questions and
Answers pdf

50 TOP MongoDB
Interview Questions &
Answers pdf download

15 TOP Linux FTP


Interview Questions &
Answers pdf download

15 TOP YUM Interview


Questions & Answers pdf
download

15 TOP RPM Interview


Questions & Answers pdf

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 16 of 17
55 TOP PHP MULTIPLE CHOICE QUESTIONS AND ANSWERS PDF - REAL TIME Interview Questions 26/12/1940 Saka, 7.30 PM

download

Copyright 2019 , REAL TIME Interview Questions , Theme by Discount Promo Codes

http://realtimeinterviewquestions.com/2017/03/php-multiple-choice-questions/ Page 17 of 17

S-ar putea să vă placă și