PHP Multiple Choice Questions

  1. Which of the following tags is not a valid way t o begin and end a PHP code block?
    1. <% %>
    2. <! !>
    3. <? ?>
    4. <?= ?>
Answer :
B
Explanation:
Added By : Manish Kumar

  1. Which of the following is invalid PHP code?
    1. $_20
    2. &$myVar
    3. $20_var
    4. ${"var"}
Answer :
C
Explanation:

Variable in PHP always start with $ sign and are sequence of character and numbers plus underscore however Variable cannot start with number.

Added By : Manish Kumar


  1. Which is correct syntax to declare constant?
    1. define("CONSTANT", "Placement Question");
    2. const CONSTANT = 'Placement Question';
    3. constant CONSTANT = 'Placement Question';
    4. A & B
Answer :
D
Explanation:
Added By : Rohit

  1. Which is correct statement to terminate PHP statement?
    1. Semicolon at the end of each statement
    2. The closing tag of a block of PHP code automatically implies a semicolon;
    3. Colon at the end of each statement
    4. A & B
Answer :
D
Explanation:
Added By : Rohit

  1. What option should be enable to allow php short tags in php.ini?
    1. short_tag
    2. short_open_tag
    3. asp_tag
    4. allow_all_tag
Answer :
B
Explanation:
short_open_tag=On to enable PHP short tag.
Added By : Rohit

  1. __FILE__ is ?
    1. Language construct
    2. Keyword
    3. Compile-time constant
    4. None of the above
Answer :
C
Explanation:
Added By : Abhijit Kumar


  1. list in PHP is ?
    1. Language construct
    2. Keyword
    3. A & C Both
    4. None of the above
Answer :
A
Explanation:
Added By : Abhijit Kumar

  1. PHP allow which commenting style?
    1. /* */
    2. //
    3. #
    4. All the above
Answer :
D
Explanation:
Added By : Abhijit Kumar

Social Sharing
Search