Re: MySQL Conditional Trigger

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fortuno, Adam wrote:
All,

Chris makes a good point i.e., "unknown compared to anything is
unknown". His comment made me want to clarify my earlier note. In my
earlier example, I wasn't suggesting that-that logic be coded in the
database. I was assuming it would be in the page:

<?php

$TestNullValue = NULL;

If ($TestNullValue) {
	print "Evaluates to true!";
} else {
	print "Evaluates to false!";
}

?>

I tested this, and it worked. Here is why, PHP (like pretty much every
other language) silently casts a NULL to false:
"When converting to boolean, the following values are considered FALSE:

- the boolean FALSE itself - the integer 0 (zero) - the float 0.0 (zero) - the empty string, and the string "0" - an array with zero elements - an object with zero member variables (PHP 4 only)
 - the special type NULL (including unset variables)" ("Booleans",
php.net, 05 Dec. 2008).

If you use the shortcut php check, but you can do it the longer way.

if ($value !== null) {
...
}

Can you turn off email notifications too please? It's rather annoying when it's on a public mailing list.

--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux