Home > PHP, ruby > Quiz

Quiz

January 12th, 2011 Leave a comment Go to comments

We found a small bug in our codebase the other days, which led to a funny discussion about how PHP acts in different situations.

Try look at the following example. What will $i be?

$i = 10;
$i = $i + 2 + $i = $i + 5;
echo $i;

Give an answer before you plot it in the console :)

Ruby will give the same answer:

i = 10
i = i + 2 + i = i + 5
puts i

Here is another one:

$d = 0;
$d = 2 + $d == $d = $d + 2;
echo $d;
Categories: PHP, ruby Tags:
  1. No comments yet.
  1. No trackbacks yet.