Dear Readers, Welcome to PHP Objective Questions have been designed specially to get you acquainted with the nature of questions you may encounter during your Job interview for the subject of PHP. These Objective type PHP Questions are very important for campus placement test and job interviews. As per my experience good interviewers hardly plan to ask any particular question during your Job interview and these model questions are asked in the online technical test and interview of many Medical companies.
a. FALSE
b. 0
c. “0”
d. “FALSE”
e. 1
f. NULL
Ans: d and e
Class Insurance
{
function clsName()
{
echo get_class($this);
}
}
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
a. echo()
b. isset()
c. print()
d. All of the above
Ans: b
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
a. Netscape FastTrack
b. Microsoft's Internet Information Server
c. O'Reilly's WebSite Pro
d. All of the above
Ans: d
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 different interfaces implmented by a class
Ans: d
a. real
b. double
c. decimal
d. boolean
Ans: c
$var = 10;
function fn ()
{
$var = 20;
return $var;
}
fn ();
echo $var;
a. 10
b. 20
c. Undefined Variable
d. Syntax Error
Ans: a
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
a. <
b. >
c. single quote
d. double quote
e. &
f. All of the above
Ans: f
a. Only first character will be recognised and new line will be inserted.
b. Last will not be recognised and only first 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
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
a. True
b. False
Ans: b
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
a. &
b. =
c. :?
d. ?:
e. +=
f. &&
Ans: d
a. Integer
b. String
c. Boolean
d. Array
Ans: b,d
a. +,-
b. ==, !=
c.
d. &=, |=
Ans: b
a. enctype='multipart/form-data'
b. enctype='singlepart/data'
c. enctype='file'
d. enctype='form-data/file'
Ans: a
a. echo()
b. print()
c. println()
d. display()
Ans: a,b
a. arg_num()
b. func_args_count()
c. func_num_args()
d. None of the above
Ans: c
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
a. Checkbox
b. Select
c. File
d. All of the above
Ans: b
a. It is a server side scripting language
b. A PHP file 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
a. echo
b. print
c. printf
d. All of the above
Ans: a
a. Yes
b. No
Ans: b
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
a. TRUE
b. FALSE
c. NULL
d. _FILE_
e. CONSTANT
Ans: d
$a = 10;
if ($a > 5 OR < 15)
echo 'true';
else
echo 'false';
a. true
b. false
c. No output
d. Parse Error
Ans: d
$size = X(filename);
Which function will suitably replace 'X'?
a. filesize
b. size
c. sizeofFile
d. getSize
Ans: a
a. max_file_size
b. max_execution_time
c. post_max_size
d. max_input_time
Ans: d
a. $var_1
b. $var1
c. $var-1
d. $var/1
e. $v1
Ans: c,d
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
$a = 10;
echo 'Value of a = $a';
a. Value of a = 10
b. Value of a = $a
c. Undefined
d. Syntax Error
Ans: a
$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
a. private $type = 'moderate';
b. internal $term= 3;
c. public $amnt = '500';
d. protected $name = 'Quantas Private Limited';
Ans: b
a. static
b. global
c. session_register
d. None of the above
Ans: c
a. setcookie('OrderCookie',34);
b. makeCookie('OrderCookie',34);
c. Cookie('OrderCookie',34);
d. OrderCookie(34);
Ans: a
$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
a. ^[^@ ]+@[^@ ]+.[^@ ]+$
b. ^[^@ ]+@[^@ ]+.[^@ ]+$
c. $[^@ ]+@[^@ ]+.[^@ ]+^
d. $[^@ ]+@[^@ ]+.[^@ ]+^
Ans: b
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
a. True
b. False
Ans: a
a. Type Hinting
b. Reflection
c. Magic Methods
d. Multiple Inheritance
e. Object Cloning
Ans: d
echo 30*5 . 7;
a. 150.7
b. 1507
c. 150.7
d. you can't concatenate integers
e. error will occur
Ans: b
a. include()
b. require()
c. nowarn()
d. getFile(false)
Ans: a
a. int(3*4)
b. int(12)
c. 3*4
d. 12
e. None of the above
Ans: b
a. count($POST_VARS);
b. count($POST_VARS_PARAM);
c. count($_POST);
d. count($HTTP_POST_PARAM);
Ans: c
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
a. echo()
b. print()
c. println()
d. display()
Ans: a,b
a. session(start);
b. session();
c. session_start();
d. begin_session();
Ans: c
$a = 10;
echo 'Value of a = $a';
a. Value of a = 10
b. Value of a = $a
c. Undefined
d. Syntax Error
Ans: a
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 defined in the body
Ans: d
a. mail($to,$subject,$body)
b. sendmail($to,$subject,$body)
c. mail(to,subject,body)
d. sendmail(to,subject,body)
Ans: a
a. __call, __get, __set
b. _get,_set,_load
c. __get,__set,__load
d. __overload
Ans: a
a. Domxml document
b. Odbc link
c. File
d. All of the above
Ans: d
a. Yes
b. No
Ans: a