250+ TOP PHP Coding MCQs on Operators and Answers

Tough PHP Interview Questions & Answers on “Operators – 5”.

1. What will be the output of the following PHP code?

  1. $i = 0; $j = 1; $k = 2;
  2. print !(($i + $k) < ($j - $k));
  3. ?>

a) 1
b) true
c) false
d) 0
Answer: a
Clarification: True is 1.

2. What will be the output of the following PHP code?

  1. $i = 0;$j = 1;$k = 2;
  2. print !(( +  + $i + $j) > ($j - $k));
  3. ?>

a) 1
b) no output
c) error
d) 0
Answer: b
Clarification: The equation outputs false .

3. What will be the output of the following PHP code?

  1. $i = 0;$j = 1;$k = 2;
  2. print (( +  + $i + $j) >! ($j - $k));
  3. ?>

a) 1
b) no output
c) error
d) 0
Answer: a
Clarification: Negation of a number is 0.

4. What will be the output of the following PHP code?

  1. $a = 0x6db7;
  2. print $a<<6;
  3. ?>

a) 1797568
b) no output
c) error
d) 0x6dc0
Answer: a
Clarification: The output is in decimal.

5. What will be the output of the following PHP code?

  1. $a  =  'a' ;
  2. print $a * 2;
  3. ?>

a) 192
b) 2
c) error
d) 0
Answer: d
Clarification: Characters cannot be multiplied.

6. What will be the output of the following PHP code?

  1. $a  =  '4' ;
  2. print  +  + $a;
  3. ?>

a) no output
b) error
c) 5
d) 0
Answer: c
Clarification: The character is type casted to integer before multiplying.

7. What will be the output of the following PHP code?

  1. $a  =  '12345';
  2. print "qwe{$a}rty";
  3. ?>

a) qwe12345rty
b) qwe{$a}rty
c) error
d) no output

Answer: a
Clarification: {$}dereferences the variable within.

8. What will be the output of the following PHP code?

  1. $a  =  '12345';
  2. print "qwe".$a."rty";
  3. ?>

a) qwe12345rty
b) qwe$arty
c) error
d) no output
Answer: a
Clarification: . dereferences the variable/string within.

9. What will be the output of the following PHP code?

  1. $a  =  '12345';
  2. echo 'qwe{$a}rty';
  3. ?>

a) qwe12345rty
b) qwe{$a}rty
c) error
d) no output
Answer: b
Clarification: qwe{$a}rty, single quotes are not parsed.

10. What will be the output of the following PHP code?

  1. $a  =  '12345';
  2. echo "qwe$arty";
  3. ?>

a) qwe12345rty
b) qwe$arty
c) qwe
d) error
Answer: c
Clarification: qwe, because $a became $arty, which is undefined.

To practice all tough interview questions on PHP, here is complete set of 250 + Multiple Choice Questions and Answers on PHP.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top