Q:

php one line if statement strange behavior in string

Why does the following code print Five ?
$a = 6;
$b = 'Hey, The Value of $a Is '.
    ($a == 1)?'One':''.
    ($a == 5)?'Five':''.
    ', Period.';
echo $b;

Why only Five??

A:

Because you should use () for each shorthand  if statement:
$a = 5;
$b = 'Hey, The Value of $a Is '.
(($a == 1) ? 'One' : '') . (($a == 5) ? 'Five' : '') .
', Period.';
echo $b;

It is happening so because $b is assigned at first to the 'Hey, The Value of $a Is ', then to the One(as shorthand if syntax is not valid), after that it is assigned to Five (again, by coincidence as it stays the first) and as (again) syntax is not valid the value is not concatenated with ',Period.'. So, to sum up, this string is just an order of three assignments and as the third is Five then it is printed in the browser.
Example

