What does the function isset() in PHP check for?
Correct answer
A. Checks if a variable is set and not null
11 views
A. Checks if a variable is set and not null
11 views
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.
Not sure why the answer is A? Ask here and get an explanation.