mercredi 6 février 2019

Check if variable has value the opposite way?

I have this PHP if statement that I am trying to firgure out. I know what the result is, but I have not seen this before (probably my bad). Who can help me understand the code below? Why is $a showing and not $b? Because $a is first in line?

<?php
$a = 'has a value';
$b = 'this one too!';
if (($href = $a) || ($href = $b)) { 
    echo $href;
    //Result is 'has a value'.  
}
?>

Aucun commentaire:

Enregistrer un commentaire