Home

Php Programming MCQ Question with Answer

Php Programming MCQ with detailed explanation for interview, entrance and competitive exams. Explanation are given for understanding.

Download Php Programming MCQ Question Answer PDF

Question No : 50
Which one of the following function is used to start a session?

start_session()
session_start()
session_begin()
begin_session()

Question No : 51
What will be the output of the following PHP code?

 <?php  $a1 = array_fill(3, 4, blue);
$b1 = array_fill(0, 1, red);
print_r($a1);
echo
;
print_r($b1);
?>

Array ( [3] => blue [4] => blue) 
Array ( [0] => red )
Array ( [4] => blue [5] => blue [6] => blue) 
Array ( [0] => red )
Array ( [3] => blue [4] => blue [5] => blue [6] => blue ) 
Array ()
Array ( [3] => blue [4] => blue [5] => blue [6] => blue ) 
Array ( [0] => red )

Question No : 52
What will be the output of the following PHP code ?

 <?php  $i = ;
while ($i = 10){ print hi;
}print hello;
?>

hello
infinite loop
hihello
error

Question No : 53
What will be the output of the following PHP code?

 <?php  $a1 = array(a=>red, b=>green, c=>blue, d=>yellow);
$a2 = array(e=>red, f=>green, g=>blue);
$result = array_diff($a1, $a2);
print_r($result);
?>

Array ( [d] => yellow )
Array ( [c] => blue )
Array ( [a] => red )
Array ( [e] => yellow )

Question No : 54
What will be the output of the following PHP code ?

 <?php  define(VAR_NAME,test);
${VAR_NAME} = value;
echo VAR_NAME;
echo ${VAR_NAME};
?>

test
testtest
testvalue
error, constant value cannot be changed

Question No : 55
Which one of the following is the default PHP session name?

PHPSESSID
PHPSESID
PHPSESSIONID
PHPIDSESS

Question No : 56
Which one of the following is the very first task executed by a session enabled page?

Delete the previous session
Start a new session
Check whether a valid session exists
Handle the session