1. Home
  2. Computer Science MCQs
  3. PHP
  4. What does the function isset() in PHP check for?

Added 23 Jan 2024

What does the function isset() in PHP check for?

  1. Checks if a variable is set and not null Correct answer
  2. Checks if a variable is defined
  3. Checks if a variable is empty
  4. Checks if a variable is numeric

Correct answer

A. Checks if a variable is set and not null

11 views

MCQSEXAM

Explanation

isset() returns true only when a variable is set and is not null. It is the standard guard before reading form input, e.g. isset($_POST['email']).

Compare it with empty(), which is also true for 0, "" and an empty array, and is_numeric(), which tests for a number. A variable that is declared but assigned null makes isset() return false.

Want more practice? Try the full set of Computer Science MCQs on MCQsExam.com.

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More PHP MCQs

Practise all PHP MCQs

Similar MCQs