1 Nov 2008 04:22
Fwd: Bitwise operation giving wrong results
sean greenslade <zootboysean <at> gmail.com>
2008-11-01 03:22:54 GMT
2008-11-01 03:22:54 GMT
---------- Forwarded message ----------
From: sean greenslade <zootboysean <at> gmail.com>
Date: Fri, Oct 31, 2008 at 11:22 PM
Subject: Re: [PHP] Bitwise operation giving wrong results
To: Yeti <yeti <at> myhich.com>
Cool, thanks. It worked. I didn't know you typeset PHP like that.
On Thu, Oct 30, 2008 at 3:42 AM, Yeti <yeti <at> myhich.com> wrote:
> 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;
> }
> ?>
>
--
--Zootboy
--
--
--Zootboy
RSS Feed