Question:

What is the value of "$day" in the below code?

Answer:

$wed= 1;    
$day = ($wed==1) ? 'today' : 'tommorrow';
// $day is now set to 'today'

Companies often ask about the ternary operator (?). which is simply a shorthand for if else statements.

http://davidwalsh.name/php-shorthand-if-else-ternary-operators


Keywords:

© 2017 QuizBucket.org