Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What will be the output of the following PHP code ? <?php one = 1; two = 2; thre

ID: 3809271 • Letter: W

Question

What will be the output of the following PHP code ?

<?php

one = 1;

two = 2;

three = 3;

four = 4;

print "one / two + three / four";

?>

A. 0.75
      

B. 0.25
      

C. 1.25
      

D. Error

What will be the output of the following PHP code ?

<?php

print $red ;

?>

A. 0
      

B. Nothing (also no error)
      

C. True
      

D. Error

What will be the output of the following PHP code ?

<?php

$on$e = 1;

$tw$o = 2;

$thre$e = 3;

$fou$r = 4;

print "$on$e / $tw$o + $thre$e / $fou$r" ;

?>

A. 0.75
      

B. 0.05
      

C. 1.25
      

D. Error

What will be the output of the following PHP code ?

<?php

$4four = 4;

$3three = 3;

$2two = 2;

print "$4four + $3three / $2two - 1";

?>

        

A. 4.5
      

B. 7
      

C. 3.5
      

D. Error

What will be the output of the following PHP code ?

<?php

int $one = 1;

print "$one";

?>

A. 0
      

B. 1
      

C. $one
      

D. Error

Explanation / Answer

1)

the output is D which is an error reporting the syntyax error at line 2:>

which should be $one = 1; and similarly for all the variables.

2)

the output is D which is an error reporting the syntyax error at line 2: $red is not defined

the value of the variable $red is not defined.

3) the output is D which is an error reporting the syntyax error at line 2: unexpected $

the reason is that   $on$e is an invalid identifier in php.

4)

the output is D which is an error reporting the syntyax error at line 2: unexpected 4

the reason is that   $4four is an invalid identifier in php.

YOU CANNOT START A VARIABLE NAME WITH NUMERIC DIGITS.

5) the output is D which is an error reporting the syntyax error at line 2: unexpected $one

the reason is that PHP does not supports datatypes such as int, double, float or anything.

PLEASE READ ABOUT PHP NAMING CONVENTION OF IDENTIFIERS TO GET A CLEAR UNDERSTANDING OF PHP RULES.

CHEERS

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote