At 12:47 PM +0100 4/12/11, Richard Quadling wrote:
Putting () around ternary's is a "best practise". <?php echo 'Are we ready to go? ', isset($go) ? 'Yes we are.' : 'No we are not.', ' Ready state completed', PHP_EOL; $go = true; echo 'Are we ready to go? ', isset($go) ? 'Yes we are.' : 'No we are not.', ' Ready state completed', PHP_EOL; ?> vs. <?php echo 'Are we ready to go? ' . isset($go) ? 'Yes we are.' : 'No we are not.' . ' Ready state completed' . PHP_EOL; $go = true; echo 'Are we ready to go? ' . isset($go) ? 'Yes we are.' : 'No we are not.' . ' Ready state completed' . PHP_EOL; ?> vs. <?php echo 'Are we ready to go? ' . (isset($go) ? 'Yes we are.' : 'No we are not.') . ' Ready state completed' . PHP_EOL; $go = true; echo 'Are we ready to go? ' . (isset($go) ? 'Yes we are.' : 'No we are not.') . ' Ready state completed' . PHP_EOL; ?> Don't run them just yet. Can you quickly and easily see the output?
Argg! :-) $ready = 'Are we ready to go? '; $yes = 'Yes we are.'; $no = 'No we are not.' echo($ready); echo(isset($go) ? $yes : $no); Cheers, tedd -- ------- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php