Examveda
Examveda

What will be the output of the following PHP code?
<?php
$color = "maroon";
$var = $color[2];
echo "$var";
?>

A. a

B. Error

C. $var

D. r

Answer: Option D

Solution(By Examveda Team)

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

Join The Discussion

Related Questions on Basic PHP