note 83562 added to language.types.null

From: Date: Sun, 01 Jun 2008 17:12:17 +0000
Subject: note 83562 added to language.types.null
Groups: php.notes 
Request: Send a blank email to php-notes+get-140050@lists.php.net to get a copy of this message
The post by <rburghol a t veetee dot edu> has nothing to do with the special NULL value. He's comparing a float (0.0) to a string ('NULL'). The special NULL value is correctly represented as a bareword (NULL), not a string ('NULL'). <?php /* start <rburghol a t veetee dot edu> example, with comment */ $tvar = 0.0; // The string 'NULL' is converted to integer 0 for the comparison if ($tvar == 'NULL') { print("Match"); } else { print("No Match"); } /* end <rburghol a t veetee dot edu> example */ // Example using actual NULL if ($tvar == NULL) { print("Match"); } else { print("No Match"); } ?> Output: Match Match It's the same result, but it's important to know what's happening and why, and how to represent NULL. ---- Server IP: 69.147.83.197 Probable Submitter: 71.255.133.253 ---- Manual Page -- http://www.php.net/manual/en/language.types.null.php Edit -- https://master.php.net/note/edit/83562 Del: integrated -- https://master.php.net/note/delete/83562/integrated Del: useless -- https://master.php.net/note/delete/83562/useless Del: bad code -- https://master.php.net/note/delete/83562/bad+code Del: spam -- https://master.php.net/note/delete/83562/spam Del: non-english -- https://master.php.net/note/delete/83562/non-english Del: in docs -- https://master.php.net/note/delete/83562/in+docs Del: other reasons-- https://master.php.net/note/delete/83562 Reject -- https://master.php.net/note/reject/83562 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#140050) next »