PHP alternative to an IF statement. A simple alternative to an if statement, which is almost like a ternary operator, is the use of AND.
Consider the following: (This does not work with
echo()
for some reason though but this is extremely useful!)
<?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 );
?>
$value = 'Jesus';
// This is a simple if statement
if( isset( $value ) )
{
print $value;
}
print '<br />';
// This is an alternative
isset( $value ) AND print( $value );
?>
All PHP Scripts on this website are provided by phpscripts4u.com where you can find all the latest PHP code snippets, plugins and libraries.