does php ternary operator only 'return' a true or false?
<p>I have a php ternary operator as follows that does not work:</p>

<pre><code> var newLoginTxt = &lt;?=$_SESSION['loginStatus']? 'Logged in' : 'Login'?&gt;;
 alert("About to set the navbar's login text to: " + newLoginTxt);
</code></pre>

<p>No alert box appears at all.</p>

<p>However this does work:</p>

<pre><code>var curLoginStatusSessionVar = &lt;?=$_SESSION['loginStatus']? 'true' : 'false'?&gt;;
alert("Testing: " + curLoginStatusSessionVar);
</code></pre>

<p>The alert box appears and says "Testing: false"</p>

<p>I have the following article seeming to say that the ternary operator in php CAN in fact return values other than 'true' or 'false':
<a href="http://davidwalsh.name/php-shorthand-if-else-ternary-operators" rel="nofollow">http://davidwalsh.name/php-shorthand-if-else-ternary-operators</a></p>

<p>Okay, even more odd -- in the code below, why does the first "Testing" alert box appear, then the 2nd "Testing" alert box NOT appear?  It's the exact same code:</p>

<pre><code>      // THIS "Testing" ALERT BOX APPEARS FINE**
var curLoginStatusSessionVar = &lt;?=$_SESSION['loginStatus']? 'true' : "false"?&gt;;
alert("Testing: " + curLoginStatusSessionVar);


var newLoginTxt = &lt;?=$_SESSION['loginStatus']? 'Logged in' : 'Login'?&gt;;
alert("About to set the navbar's login text to: " + newLoginTxt);


    // THIS IDENTICAL "Testing" ALERT BOX NEVER APPEARS**
curLoginStatusSessionVar = &lt;?=$_SESSION['loginStatus']? 'true' : 'false'?&gt;;
alert("Testing" + curLoginStatusSessionVar);
</code></pre>
