note 59815 added to function.get-magic-quotes-gpc
| From: | AndersS�rensen at osu1 dot php dot net | Date: | Fri, 16 Dec 2005 12:38:02 +0000 |
| Subject: | note 59815 added to function.get-magic-quotes-gpc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100301@lists.php.net to get a copy of this message | ||
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;
----
Manual Page -- http://www.php.net/manual/en/function.get-magic-quotes-gpc.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59815
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59815&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59815&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59815&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59815&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59815&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59815&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59815&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59815&report=yes
Search -- http://master.php.net/manage/user-notes.php