Re: Bitwise operation giving wrong results

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

 



Usually in PHP one does not take much care about the data types, but
in this case you absoloodle have to.
If you use bit operators on a character then its ascii number will be
taken instead (how should a number based operation work with a
string?)

also if you pass on $_GET params directly into ay bitwise operation
you might get some un-nice behaviour. So check them first.

<?php
$a = $b = false;
if (is_numeric($_GET['b'].$_GET['a'])) {
	$a = (int)$_GET['a'];
	$b = (int)$_GET['b'];
	echo $a & $b;
}
?>

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux