note 106012 added to control-structures.alternative-syntax
| From: | temec987 at gmail dot com | Date: | Mon, 03 Oct 2011 02:00:40 +0000 |
| Subject: | note 106012 added to control-structures.alternative-syntax | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183591@lists.php.net to get a copy of this message | ||
A simple alternative to an if statement, which is almost like a ternary operator, is the use of AND.
Consider the following:
<?php
$value = 'Jesus';
// This is a simple if statement
if( isset( $value ) )
{
print $value;
}
print '<br />';
// This is an alternative
isset( $value ) AND print( $value );
?>
This does not work with echo() for some reason. I find this extremely useful!
----
Server IP: 69.147.83.197
Probable Submitter: 173.60.62.26
----
Manual Page -- http://www.php.net/manual/en/control-structures.alternative-syntax.php
Edit -- https://master.php.net/note/edit/106012
Del: integrated -- https://master.php.net/note/delete/106012/integrated
Del: useless -- https://master.php.net/note/delete/106012/useless
Del: bad code -- https://master.php.net/note/delete/106012/bad+code
Del: spam -- https://master.php.net/note/delete/106012/spam
Del: non-english -- https://master.php.net/note/delete/106012/non-english
Del: in docs -- https://master.php.net/note/delete/106012/in+docs
Del: other reasons-- https://master.php.net/note/delete/106012
Reject -- https://master.php.net/note/reject/106012
Search -- https://master.php.net/manage/user-notes.php