Php Operators And Expressions(Engineering > Computer Science And Engineering > Php ) Questions and Answers

Question 1. What will be the output of the following PHP code ?# echo "Hello world";echo "# Hello world";
  1.    Error
  2.    # Hello world
  3.    Hello world# Hello world
  4.    Hello world
Explanation:-
Answer: Option B. -> # Hello world

Question 2. What will be the output of the following PHP code ?
  1.    Error
  2.    Nothing
  3.    Missing semicolon error
  4.    Hello World
Explanation:-
Answer: Option B. -> Nothing

Question 3. What will be the output of the following PHP code ?$color = "red";echo "$color";echo "$COLOR";echo "$Color";
  1.    redredred
  2.    red
  3.    redred
  4.    Error
Explanation:-
Answer: Option B. -> red

Question 4. What will be the output of the following PHP code ?print_r "Hello world"
  1.    Missing semicolon error
  2.    Hello World
  3.    Error
  4.    Nothing
Explanation:-
Answer: Option C. -> Error

Question 5. What will be the output of the following PHP code ?echo "Hello World"
  1.    Hello world in italics
  2.    Error
  3.    Nothing
  4.    Hello world
Explanation:-
Answer: Option A. -> Hello world in italics

Question 6. What will be the output of the following PHP code ?echo "echo "Hello World"";
  1.    Error
  2.    echo Hello world
  3.    echo “Hello world”
  4.    Hello world
Explanation:-
Answer: Option A. -> Error

Question 7. What will be the output of the following PHP code ?$color = red;echo "$color" . red ;
  1.    red
  2.    red red
  3.    error
  4.    nothing
Explanation:-
Answer: Option C. -> error

Question 8. What will be the output of the following PHP code ?< ? php < ? php echo "Hello world"; ? > ? >
  1.    Nothing
  2.    Hello world
  3.    Hello
  4.    Error
Explanation:-
Answer: Option D. -> Error

Question 9. What will be the output of the following PHP code ?$color = red;echo "$color";
  1.    $color
  2.    Error
  3.    red
  4.    red
Explanation:-
Answer: Option A. -> $color

Question 10. What will be the output of the following PHP code ?$color1 = red;$color2 = green;echo "$color1"."$color2";
  1.    red green
  2.    green
  3.    error
  4.    red
Explanation:-
Answer: Option C. -> error