"> What will be the output of the following PHP code? < ?php $color = "maroon"; "> " /> " />
Sail E0 Webinar
Question
What will be the output of the following PHP code?
< ?php
$color = "maroon";
$var = $color[2];
echo "$var" ;
?>
Options:
A .  a
B .  Error
C .  $var
D .  r
Answer: Option D


PHP treats strings in the same fashion as arrays, allowing for specific characters to be accessed via array offset notation.



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers