note 59815 deleted from function.get-magic-quotes-gpc by nlopess
| From: | nlopess@php.net | Date: | Fri, 16 Dec 2005 12:40:17 +0000 |
| Subject: | note 59815 deleted from function.get-magic-quotes-gpc by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-100302@lists.php.net to get a copy of this message | ||
Note Submitter: Anders Sørensen
----
Won't the code snippet given in this example yield undefined
behaviour at some point?
<?php
if (!get_magic_quotes_gpc())
...
?>
since get_magic_quotes_gpc() returns int (0 || 1),
then the value returned must be casted to bool before using
it in an if-statement.
I don't know the details of the if() in PHP, but in C 1 and 0
are equal to true and false, respectively.
C++ has boolean types.
Anyway, I just think (if the above example works), that it
should be changed to either be casted to bool or compared
to an actual integer---only to provide "best practice".
note: the php manual has specified the if() to specifically evaluate on boolean types!
the value in the if() must evaluate to either TRUE or FALSE.
return 0;