note 51913 added to control-structures.alternative-syntax

From: Date: Thu, 14 Apr 2005 18:31:03 +0000
Subject: note 51913 added to control-structures.alternative-syntax
Groups: php.notes 
Request: Send a blank email to php-notes+get-88028@lists.php.net to get a copy of this message
jasperbg at gmail dot com, if you are doing a quick, small comparison, the ternary operator *is* an alternative to using if...else <?php // eg... $x = 1; // long way... if($x == 1) { echo 'X is one!'; } else { echo 'X isn't one!'; } // ternary way echo (($x == 1) ? 'X is one!' : 'X isn't one!'); ?> it can save on line space... and help to compact code :) ---- Manual Page -- http://www.php.net/manual/en/control-structures.alternative-syntax.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51913 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51913&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51913&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51913&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51913&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51913&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51913&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88028) next »