Recall & Review
beginner
What does the
isset() function check in PHP?isset() checks if a variable is set and is not null. It returns true if the variable exists and has a value other than null, otherwise false.Click to reveal answer
beginner
How does
empty() behave with different variable values?empty() returns true if a variable is not set or its value is considered "empty". This includes 0, "0", "" (empty string), null, false, empty arrays, and unset variables.Click to reveal answer
intermediate
What is the difference between
is_null() and isset()?is_null() returns true only if the variable's value is exactly null. isset() returns false if the variable is null or not set at all.Click to reveal answer
beginner
What will
empty() return for a variable set to false?empty() will return true because false is considered an empty value in PHP.Click to reveal answer
intermediate
If a variable is not declared at all, what will
isset() and empty() return?isset() will return false because the variable does not exist. empty() will return true because the variable is considered empty if not set.Click to reveal answer
What does
isset($var) return if $var = null;?✗ Incorrect
isset() returns false if the variable is null.Which of these values will
empty() consider as empty?✗ Incorrect
empty() treats the string "0" as empty.What does
is_null($var) return if $var is not set?✗ Incorrect
is_null() on an unset variable throws a warning about undefined variable.If
$var = false;, what does isset($var) return?✗ Incorrect
isset() returns true because $var is set and not null.Which function returns
true for an empty array?✗ Incorrect
empty() returns true for empty arrays.Explain how
isset(), empty(), and is_null() differ in checking variable states in PHP.Think about what each function considers as 'set' or 'empty'.
You got /5 concepts.
Describe what happens when you use
empty() on a variable that is not declared.Consider how empty handles unset variables compared to isset.
You got /3 concepts.