PHP Alternative to an IF Statement

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 );
?>

All PHP Scripts on this website are provided by phpscripts4u.com where you can find all the latest PHP code snippets, plugins and libraries.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>