Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi all,
I have the following code from a google page rank script checker, but I get different results depending upon which version of PHP I use. Why would there be a difference? Is it because of the PHP version? or what OS apache is sitting on? Has something altered in PHP that affects the way these functions are calculated? - as two run on the same host just different php versions.
I have one version which works correctly, this is installed on my XP home box running apache 4.2.3 (phpdev)
I have another version which fails on my internet hosts server (RedHat) with apache 4.4.4
Another version which fails on my internet hosts server (RedHat) with apache 5.1.6
Lastly another working copy on my XP Home box running apache 5.2.0 (xampp)
The code that fails/changes is below:Code: Select all
function zeroFill($a, $b)
{
echo "zeroFill: " . $a . " " . $b . "<br/>";
$z = hexdec(80000000);
if ($z & $a)
{
$a = ($a>>1);
$a &= (~$z);
$a |= 0x40000000;
$a = ($a>>($b-1));
echo "zeroFill: za<br/>";
}
else
{
$a = ($a>>$b);
echo "zeroFill: a<br/>";
}
echo "zeroFill: " . $a . "<br/>";
return $a;
}
function mix($a,$b,$c) {
$a -= $b; $a -= $c; $a ^= (zeroFill($c,13));
echo $a . " $a<br/>"; // response up to here posted below
$b -= $c; $b -= $a; $b ^= ($a<<8);
echo $b . " $b<br/>";
$c -= $a; $c -= $b; $c ^= (zeroFill($b,13));
echo $c . " $c<br/>";
$a -= $b; $a -= $c; $a ^= (zeroFill($c,12));
echo $a . " $a<br/>";
$b -= $c; $b -= $a; $b ^= ($a<<16);
echo $b . " $b<br/>";
$c -= $a; $c -= $b; $c ^= (zeroFill($b,5));
echo $c . " $c<br/>";
$a -= $b; $a -= $c; $a ^= (zeroFill($c,3));
echo $a . " $a<br/>";
$b -= $c; $b -= $a; $b ^= ($a<<10);
echo $b . " $b<br/>";
$c -= $a; $c -= $b; $c ^= (zeroFill($b,15));
echo $c . " $c<br/>";
return array($a,$b,$c);
}Apache Version: 4.2.3 / 5.2.0 (Working)
Code: Select all
zeroFill: 1520109454 13
zeroFill: a
zeroFill: 185560
-1655620743 -1655620743Code: Select all
zeroFill: 5815076750 13
zeroFill: za
zeroFill: 524287
-2146959361 -2146959361Code: Select all
zeroFill: 5815076750 13
zeroFill: a
zeroFill: 185560
-2147298088 -2147298088Kind Regards
Matthew
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]