0 views
What does empty() return for an empty string and zero?
Asked at
AI answer
empty() returns true for both an empty string "" and the number 0. The string '0' is also considered empty. For example: empty("") === true, empty(0) === true.
Also asked at AutoSpot
- Tell us about yourself as a developer — experience, stack, projects.
- What are your salary expectations?
- Do you have experience writing and working with native SQL queries or similar low-level commands to a database?
- What AI tools do you use and for what tasks?
- What do you know about indexes? How can you determine which indexes are used in a query, and how can you tell which indexes are unnecessary or missing?
Similar questions
- What will be the output when array_search() is used in an if condition?
- What will var_dump(isset($a)) output for null and a subsequent assignment?
- Can PHP use data types, and how is this implemented?
- In PHP, can you swap characters/variables without allocating a `$temp` variable and without using functions?
- What will be the output: ```php if ((bool)$x === true) { echo 'e'; } if ($x === true) { echo 'c'; } if ((int)$x === true) { echo 'd'; } ``` What will be the output: ```php $preview = 0; if (($preview == 1) || ($preview == 'On')) { $opp = "+"; } else { $opp = "-"; } echo $opp; ``` What will be the output: ```php $arr = ["b", "o", "m"]; if (array_search('b', $arr)) { echo 'Yes'; } else { echo 'No'; } ```