Ashley Sheridan wrote:
On Wed, 2008-10-29 at 20:01 -0400, sean greenslade wrote:
I have the following code as a test:
<?php
$a = $_GET['a'];
$b = $_GET['b'];
echo  $a . " & " . $b . " = ";
$out = $a & $b;
echo $out;
//echo 15 & 2;
?>

if I set a to 15 and b to 2 in the URL like so:

test.php?a=15&b=2

it outputs zero as the answer. When I run the hard-coded '&' operation (the
commented out echo), it returns 2. I'm stumped.

In PHP a boolean true also equates to 1. You are using the & operator
though, instead of the && which I think you're looking for.

You misunderstand the question I think.

He's trying to do this:

http://www.php.net/manual/en/language.operators.bitwise.php

For the OP:

Try casting $a and $b to int's:

$a = (int)$_GET['a'];

no idea if it'll help though.

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


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

Reply via email to