Monday, 5 February 2018

echo - Strange print behaviour in PHP?




Why does the following code output 128?



    print 4 << 5; 
?>

Answer




Because it's a bitwise operator. I think it means 4 multiplied to 2^5 because that operator means




Shift the bits of $a $b steps to the left (each step means "multiply
by two")




so it's five steps. It's 4 * 2 * 2 * 2 * 2 * 2 (But I'm guessing here; everything happens at bit level).


No comments:

Post a Comment

casting - Why wasn&#39;t Tobey Maguire in The Amazing Spider-Man? - Movies &amp; TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...