note 52549 deleted from control-structures.alternative-syntax by nlopess
| From: | nlopess@php.net | Date: | Thu, 05 May 2005 16:40:15 +0000 |
| Subject: | note 52549 deleted from control-structures.alternative-syntax by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-88972@lists.php.net to get a copy of this message | ||
Note Submitter: mels at xs4all dot nl
----
From last comment:
<?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!');
?>
... this contains a syntax error, use this instead for Copy&Pasting:
<?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!");
?>
(replaced all the *right* 's with "s, so the 's in the actual words wouldn't be
parsed)