Top PHP Interview Questions (2025) Quiz

  1. Understanding Sessions

    Which PHP function is used to begin a new session or resume an existing one for maintaining user login information across multiple web pages?

    1. session_start()
    2. start_session()
    3. beginSession()
    4. init_session()
    5. session_begin()
  2. Constants vs. Variables

    In PHP, which statement correctly explains the difference between variables and constants when defining values?

    1. Variables can be changed after definition, while constants cannot be changed
    2. Constants can be changed after definition, while variables cannot
    3. Both variables and constants cannot be changed after definition
    4. Variables start with @, constants start with $
    5. Variables must be declared using define(), constants with the $ sign
  3. PEAR Meaning

    What does 'PEAR' stand for in the context of PHP libraries?

    1. PHP Extension and Application Repository
    2. PHP Easy Application Resource
    3. Personal Encryption Application Reader
    4. Processing Engine And Runtime
    5. PHP Enhanced Algorithm Reference
  4. Variable Variables

    If $message = 'hello' and $$message = 'world', what is the value of $$message in PHP?

    1. 'world'
    2. 'hello'
    3. $message
    4. '$world'
    5. 'message'
  5. Case Sensitivity

    Is PHP considered a case-sensitive programming language in all situations?

    1. No, variable names are case-sensitive but function names are not
    2. Yes, everything is case-sensitive
    3. No, keywords are case-sensitive but variables are not
    4. Yes, except for constants
    5. No, PHP is not case-sensitive at all
  6. Array Types

    Which of the following is NOT a valid type of array in PHP?

    1. Circle array
    2. Indexed array
    3. Associative array
    4. Multidimensional array
    5. All of the above are valid
  7. Cookie Creation

    Which function is used in PHP to send a cookie to the user's browser?

    1. setcookie()
    2. send_cookie()
    3. cookie_set()
    4. makecookie()
    5. create_cookie()
  8. Hashing Passwords

    What is the most commonly recommended PHP function for safely hashing passwords?

    1. password_hash()
    2. crypt_password()
    3. hashpass()
    4. md5()
    5. sha1()
  9. Require vs. Include

    Between require() and include(), what is the main difference during script execution?

    1. require() causes a fatal error if the file is missing; include() only throws a warning
    2. include() causes a fatal error, require() only throws a warning
    3. Both stop the script immediately if the file is missing
    4. Both only show a notice if the file is missing
    5. require() and include() are identical in every way
  10. Error Control Operator

    What is the function of the '@' operator when placed before a PHP expression?

    1. It suppresses error messages that would otherwise be generated by the expression
    2. It concatenates two strings
    3. It executes the expression asynchronously
    4. It acts as a comment delimiter
    5. It makes the variable a constant