How to make php code "echo 62837 << -16;" return same result between windows and linux?
windows result:-176881664
linux result:-759700962142060544
How to make php code "echo 62837 << -16;" return same result between windows and linux?
windows result:-176881664
linux result:-759700962142060544
Shifting by a negative number throws an exception in PHP 7+ so it's obviously invalid to do so.
Fatal error: Uncaught ArithmeticError: Bit shift by negative number
In C, it invokes undefined behavior, see: Left shifting with a negative shift count
To answer your question: You can't make code that invokes undefined behavior return consistent results across platforms. That code needs to be modified to not shift by a negative number.