Create New Post

PHP MCQs - 1

  1. What does PHP stand for?

    • A) Personal Home Page
    • B) Preprocessed Hypertext Processor
    • C) PHP: Hypertext Preprocessor
    • D) Hypertext Markup Language

    Answer: C) PHP: Hypertext Preprocessor

  2. Which of the following is not a valid PHP variable name?

    • A) $my_var
    • B) $myVar123
    • C) $_myVar
    • D) $123myVar

    Answer: D) $123myVar

  3. What is the correct way to start a PHP block of code?

    • A) <php>
    • B) <?php
    • C) <?
    • D) <?

    Answer: B) <?php

  4. Which of the following PHP functions is used to open a file for writing?

    • A) fopen("filename", "r")
    • B) fopen("filename", "w")
    • C) fopen("filename", "a")
    • D) file_get_contents("filename")

    Answer: B) fopen("filename", "w")

  5. What does the function echo do in PHP?

    • A) Outputs one or more strings
    • B) Returns a value
    • C) Parses XML
    • D) Creates an array

    Answer: A) Outputs one or more strings

  6. How do you comment out a single line in PHP?

    • A) // Comment
    • B) /* Comment */
    • C) # Comment
    • D) <!-- Comment -->

    Answer: A) // Comment

  7. What is the correct way to end a PHP statement?

    • A) ;
    • B) :
    • C) ,
    • D) .

    Answer: A) ;

  8. Which function is used to check if a variable is an array in PHP?

    • A) is_array()
    • B) array()
    • C) isArray()
    • D) check_array()

    Answer: A) is_array()

  9. What does the PHP isset() function do?

    • A) Checks if a variable has a value
    • B) Checks if a variable is empty
    • C) Checks if a variable is set and not null
    • D) Checks if a variable is initialized

    Answer: C) Checks if a variable is set and not null

  10. Which of the following is not a valid PHP comparison operator?

    • A) ==
    • B) ===
    • C) ><
    • D) !=

    Answer: C) ><

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

78583