Test Series - php

Test Number 39/39

Q: What will be the output of the following PHP code?

A. Error
B. Hello World
C. Nothing
D. Missing semicolon error
Solution: If you need to output something onto the screen you’ll need to use echo or print_r.
Q: What will be the output of the following PHP code?

A. Error
B. Hello World
C. Nothing
D. Missing semicolon error
Solution: The statement should be print_r(‘Hello World’) to print Hello world. Also if there is only one line then there is no requirement of a semicolon, but it is better to use it.
Q: What will be the output of the following PHP code?

A. Hello world1 Hello world2 Hello World3
B. Hello world1 Hello world2 Hello World3
C. Error
D. Hello world1 Hello world3
Solution: In PHP, all user-defined functions, classes, and keywords (e.g. if, else, while, echo, etc.) are case-insensitive.
Q: What will be the output of the following PHP code?

A. redredred
B. redred
C. red
D. Error
Solution: In PHP, all variables are case-sensitive.
Q: What will be the output of the following PHP code?

A. # Hello world
B. Hello world# Hello world
C. Hello world
D. Error
Solution: # is a single line comment.
Q: What will be the output of the following PHP code?

Hello World"
?>
A. Hello world
B. Hello world in italics
C. Nothing
D. Error
Solution: You can use tags like italics, bold etc. inside php script.
Q: What will be the output of the following PHP code?

A. Hello world
B. echo “Hello world”
C. echo Hello world
D. Error
Solution: It would have printed echo “Hello world” if we have put backslash doublequotes just before and just after Hello World string.
Q: What will be the output of the following PHP code?


?>
A. HELLO WORLD
B. Hello world
C. Nothing
D. Error
Solution: You can not have php tags inside a php tag.
Q: What will be the output of the following PHP code?

A. red
B. $color
C.  ed
D. Error
Solution: To print red remove the .

You Have Score    /9