-4

Possible Duplicate:
What's the difference between is_null($var) and ($var === null)?

Is there any difference between following code:

if(is_null($x)) { ...

and

if($x===null) { ...
Andy
  • 49,085
  • 60
  • 166
  • 233
Handsome Nerd
  • 17,114
  • 22
  • 95
  • 173
  • 2
    Is the documentation not enough? [Read the comments](http://php.net/manual/en/function.is-null.php) and [Google seems to have plenty of results about this - you might want to consider `===` as well!](http://hakre.wordpress.com/2011/03/29/php-is_null-vs-null/) – ta.speot.is Apr 29 '12 at 06:18
  • http://stackoverflow.com/questions/4662588/whats-the-difference-between-is-nullvar-and-var-null – Sujit Agarwal Apr 29 '12 at 06:21
  • 2
    this question shouldnt be upvoted uselessly. Many exact duplicates already exist – Sujit Agarwal Apr 29 '12 at 06:21

1 Answers1

2

Yes. == is a loose comparison, meaning a lot more than just NULL will result in true in the second version. See the type comparison tables.

DCoder
  • 12,962
  • 4
  • 40
  • 62