note 52549 added to control-structures.alternative-syntax
| From: | mels at xs4all dot nl | Date: | Thu, 05 May 2005 12:00:54 +0000 |
| Subject: | note 52549 added to control-structures.alternative-syntax | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-88962@lists.php.net to get a copy of this message | ||
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)
----
Manual Page -- http://www.php.net/manual/en/control-structures.alternative-syntax.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+52549
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52549&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52549&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52549&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52549&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52549&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+52549&report=yes
Search -- http://master.php.net/manage/user-notes.php