开发者

Generating same result with bindec on different systems

开发者 https://www.devze.com 2023-04-13 01:08 出处:网络
I am curious if it is possible to generate the same results with bindec method in php, on different systems.

I am curious if it is possible to generate the same results with bindec method in php, on different systems.

The thing is, my function(which uses the bindec method) works perfectly when I test on my Windows 7 64 bit machine, but when I transfer the code to my web server(running linux), I get different results. I have narrowed my problem down to the bindec method, so I know that it is causing the problem.

Thanks, Rob

Here is the function. I was in need of the XOR operator, but that was generating a different result on my machine and my server, so I wrote my own to see if that would work.

function MyXOR($input, $key){
    $bin_data = decbin($input);
    $bin_key = decbi开发者_JAVA百科n($key);
    $result_string = "";
    $len_data = strlen($bin_data);
    $len_key = strlen($bin_key);
    for($i = 0; $i < $len_data; $i++){
        if($bin_data{$i} == $bin_key{$i % $len_key}){
                $result_string .= 0;
            } else {
                $result_string .= 1;
        }
    }

    return bindec($result_string);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号