note 60433 deleted from function.echo by betz

From: Date: Wed, 30 Aug 2006 16:48:28 +0000
Subject: note 60433 deleted from function.echo by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-116515@lists.php.net to get a copy of this message
Note Submitter: the dot only dot storm at gmail dot com ---- In reply to lorenpr at gmail dot com: "I hope this ternary thing isn't overkill. Last thing - I would just like to make you aware of the side effect when you do this statement, <?php echo $some_var ? print 'true': print 'false'; ?> The result would be either 'true1' or 'false1', depending on whether $some_var is true or false respectively. This happens because of what I mentioned earlier. Figure it out." The reason it prints the 1 because whether the variable is true or false, in this case, print will always return 1 (true) Meaning this is the same thing: <?php echo print($some_var ? 'true' : 'false'); ?> print($some_var ? 'true' : 'false') = 1 So you echo 1, after the print takes place.

« previous php.notes (#116515) next »