note 106012 deleted from control-structures.alternative-syntax by salathe
| From: | salathe@php.net | Date: | Mon, 21 Sep 2020 14:36:36 +0000 |
| Subject: | note 106012 deleted from control-structures.alternative-syntax by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215220@lists.php.net to get a copy of this message | ||
Note Submitter: temec987 at gmail dot com
----
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!