Replace two variable values without creating a third variable

It is not really a real-life example rather a theoretical one - because who wants to replace two variable values without creating a third variable. Nevertheless, you might face this theoretical question on job interiews and it is definitely an advantage if you can answer it :)

Let's see the code:

<?php
    $a = 10;
    $b = 20;
    $a = $a + $b; // $a = 10 + 20 = 30
    $b = $a - $b; // $b = 30 - 20 = 10
    $a = $a - $b; // $a = 30 - 10 = 20
?>

 
Category: