PHP MCQs with answers Page - 123

Here, you will find a collection of MCQ questions on PHP. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 832.27K Points
Coach

Q. Which PDO method is used to prepare an SQL statement?

  • (A) query()
  • (B) execute()
  • (C) prepare()
  • (D) bind()

A

Admin • 832.27K Points
Coach

Q. Which PDO method executes a prepared statement?

  • (A) run()
  • (B) execute()
  • (C) query()
  • (D) fetch()

A

Admin • 832.27K Points
Coach

Q. Which PDO fetch mode returns an associative array?

  • (A) PDO::FETCH_NUM
  • (B) PDO::FETCH_OBJ
  • (C) PDO::FETCH_ASSOC
  • (D) PDO::FETCH_BOTH

A

Admin • 832.27K Points
Coach

Q. Which PDO fetch mode returns an object?

  • (A) PDO::FETCH_OBJ
  • (B) PDO::FETCH_NUM
  • (C) PDO::FETCH_ASSOC
  • (D) PDO::FETCH_CLASS

A

Admin • 832.27K Points
Coach

Q. Which method fetches all rows from a PDO result set?

  • (A) fetch()
  • (B) fetchRow()
  • (C) fetchAll()
  • (D) getAll()

A

Admin • 832.27K Points
Coach

Q. Which PHP function hashes a password securely?

  • (A) md5()
  • (B) sha1()
  • (C) password_hash()
  • (D) crypt()

A

Admin • 832.27K Points
Coach

Q. Which function verifies a hashed password?

  • (A) password_check()
  • (B) password_verify()
  • (C) hash_verify()
  • (D) verify_password()

A

Admin • 832.27K Points
Coach

Q. Which PHP function prevents Cross-Site Scripting (XSS)?

  • (A) strip_tags()
  • (B) htmlspecialchars()
  • (C) htmlentities()
  • (D) All of the above

A

Admin • 832.27K Points
Coach

Q. Which PHP function removes HTML and PHP tags?

  • (A) htmlspecialchars()
  • (B) htmlentities()
  • (C) strip_tags()
  • (D) remove_tags()

A

Admin • 832.27K Points
Coach

Q. Which HTTP method is considered safest for retrieving data?

  • (A) POST
  • (B) PUT
  • (C) DELETE
  • (D) GET

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ