What will be the output of the following PHP code ?
<?php
$cars = array("Volvo", "BMW", "Toyota");
echo "My car is a {$cars[0]}";
?>
<?php
$cars = array("Volvo", "BMW", "Toyota");
echo "My car is a {$cars[0]}";
?>
A. My car is a Volvo
B. My car is a BMW
C. My car is a Toyota
D. Error
Answer: Option A
Solution(By Examveda Team)
In the echo statement the {$cars[0]} is replaced by the 1st element in cars that is Volvo.Related Questions on Operators and Expressions in php
What will be the output of the following PHP code ?
<?php
"Hello World"
?>
A. Error
B. Hello World
C. Nothing
D. Missing semicolon error
What will be the output of the following PHP code ?
<?php
print_r "Hello world"
?>
A. Error
B. Hello World
C. Nothing
D. Missing semicolon error
A. redredred
B. redred
C. red
D. Error
A. # Hello world
B. Hello world# Hello world
C. Hello world
D. Error
Join The Discussion