note 73627 added to language.basic-syntax

From: Date: Mon, 05 Mar 2007 01:19:09 +0000
Subject: note 73627 added to language.basic-syntax
Groups: php.notes 
Request: Send a blank email to php-notes+get-124078@lists.php.net to get a copy of this message
Regarding the comment by rosswilliams at advocacytechnologies dot org: Your suspicion is correct. The following all behave exactly the same: <?php // output the answer by escaping if ($true_or_false) { ?> <p>The value of $true_or_false is true.</p> <?php } else { ?> <p>The value of $true_or_false is false.</p> <?php } // use echo to do the same thing - more effecient and easier to read in my opinion if ($true_or_false) { echo '<p>The value of $true_or_false is true.</p>'; } else { echo '<p>The value of $true_or_false is false.</p>'; } // use ? : operators on entire string echo ($true_or_false) ? '<p>The value of $true_or_false is true.</p>' : '<p>The value of $true_or_false is false.</p>'; // use ? : operators only on the pertinent bit, to save space echo '<p>The value of $true_or_false is ' . (($true_or_false) ? 'true' : 'false') . '.</p>'; ?> ---- Server IP: 69.147.83.197 Probable Submitter: 64.230.17.172 ---- Manual Page -- http://www.php.net/manual/en/language.basic-syntax.php Edit -- https://master.php.net/note/edit/73627 Del: integrated -- https://master.php.net/note/delete/73627/integrated Del: useless -- https://master.php.net/note/delete/73627/useless Del: bad code -- https://master.php.net/note/delete/73627/bad+code Del: spam -- https://master.php.net/note/delete/73627/spam Del: non-english -- https://master.php.net/note/delete/73627/non-english Del: in docs -- https://master.php.net/note/delete/73627/in+docs Del: other reasons-- https://master.php.net/note/delete/73627 Reject -- https://master.php.net/note/reject/73627 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#124078) next »