Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // http://www.zachstronaut.com/posts/2009/02/09/careful-with-php-empty.html
- // $mystring is NOT defined
- //$mystring = null;
- if (empty($mystring)) {
- // the condition passes without a warning
- }
- if ($mystring == null) {
- // the condition passes WITH a warning
- }
- if (!isset($mystring) || $mystring == null) {
- // the condition passes without a warning
- //
- // this conditional is a suitable replacement for empty() when
- // dealing with strings
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement