note 41599 added to language.operators.logical

From: Date: Fri, 16 Apr 2004 06:51:49 +0000
Subject: note 41599 added to language.operators.logical
Groups: php.notes 
Request: Send a blank email to php-notes+get-68188@lists.php.net to get a copy of this message
Note that XOR doesn't actually an integer. This doesn't matter in PHP alone since it's typecasting is so flexible, but if you're interacting with other systems (SQL, for example) it can be problematic. For example: <? $a = 0; $b = 1; $test = $a xor $b; // Assuming val is an integer in the database, this will always assign 0 mysql_query("INSERT INTO table (val) VALUES ($test)"); // To make this work properly, you have to use intval() mysql_query("INSERT INTO table (val) VALUES (" . intval($test) . ")"); ?> ---- Manual Page -- http://www.php.net/manual/en/language.operators.logical.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41599 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41599&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41599&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#68188) next »