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
Answers
Answered by
1
hi there,
Option D is correct.
PHP treats strings in the same fashion as arrays, allowing for specific characters to be accessed via array offset notation.
Option D is correct.
PHP treats strings in the same fashion as arrays, allowing for specific characters to be accessed via array offset notation.
Answered by
0
PHP stands for Personal Home Page - PHP HyperText Preprocessor.
IT is embedded into HTML and is used in various systems involving the web, like templates or content mangements.
Option D is the right answer here.
PHP treats everything inside " " (double quotes) as strings.
This is the same way as arrays which permit specific characters to be accessed through array offset notation.
Similar questions
Environmental Sciences,
6 months ago
Math,
6 months ago
Computer Science,
1 year ago
Computer Science,
1 year ago
Math,
1 year ago
Biology,
1 year ago