News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Brian Moon's Blog:
Null vs. isset()
January 29, 2009 @ 09:34:59

In this new post to his blog, Brian Moon compares two things that, on the outside, might seem a lot alike but do have their differences under the hood - a null value and the isset function.

I am working with a newcomer to PHP and he asked me about setting a variable to null and how to check that. He had found some example or information that showed that setting a varaible equal to null would unset the variable. So, he was unclear if he could then reliably check if the variable was equal to null. Having avoided null like the plague in my years of PHP, I was not sure. So, I mocked up a quick script to see what the states of a variable are in relation to null.

His test verified that a variable, set equal to null will be found to be equal to null, will be set (isset) and will be found empty by PHP's empty

0 comments voice your opinion now!
null value variable compare isset empty


blog comments powered by Disqus

Similar Posts

Sebastian Bergmann's Blog: Flickr: The Real World PHP 5 Benchmark

DZone.com: Practical PHP Refactoring: Encapsulate Downcast (and Wrapping)

Davey Shafik's Blog: Mini-Review: Zend Guard vs IonCube PHP Encoder

Jani Hartikainen's Blog: Three PHP mistakes that will cause you debugging nightmares

Adam Bard: The Same App 4 Times: PHP vs Python vs Ruby vs Clojure


Community Events

Don't see your event here?
Let us know!


development laravel opinion podcast framework api release extension psr7 conference interview introduction unittest laravel5 series wordpress voicesoftheelephpant library community language

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework