Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

32 to 64 bit "Gotchas" in PHP

Last weekend I changed webhosts for my website. The host server I was on was a 32-bit OS and the one I moved to is 64-bit. Unexpectedly, some of my PHP scripts started giving incorrect results.

In my case the << and >> (bit shift) operations were the culprit. I ended up having to mask the result with 0xFFFFFFFF and then changing the result if negative for it to work as it did before.

Are there any other possible problems in my PHP scripts I should look for?

like image 981
lkessler Avatar asked Dec 29 '08 13:12

lkessler


2 Answers

It's a high level language, so anything non-bit related (bitwise operators, bitshift) will be the same.

like image 69
edef Avatar answered Oct 04 '22 02:10

edef


An integer may be 64bit instead of 32bit. There are some bizarre cases where this may cause problems.

like image 37
Zoredache Avatar answered Oct 04 '22 01:10

Zoredache