1. Using if () { }
if ($value) { }
Examples:
<?php if () { ?> // stuff here <?php } ?>
<?php if ( is_active_sidebar( 'welcome' ) ) { ?> <div class="welcome-widget"> <?php dynamic_sidebar( 'welcome' ); ?> </div> <?php } ?>
2. Alternate syntax using if () : endif;
if ($value): endif;
Examples:
<?php if (): ?> // stuff here <?php endif; ?>
<?php if ( is_active_sidebar( 'welcome' ) ): ?> <div class="welcome-widget"> <?php dynamic_sidebar( 'welcome' ); ?> </div> <?php endif; ?>
3. The Ternary Operator ? :
Basic Form:
<?php $outcome = ( 2 + 2 = 4 ) ? "The statement is TRUE" : "The statement is FALSE";
Example:
<?php $greeting = ($name = Steve) ? "Good to see you again, Steve!" : "Hi, what's your name?";