Created
March 21, 2012 11:17
-
-
Save NeilJS/2146288 to your computer and use it in GitHub Desktop.
PHP if statements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PHP if statements around html blocks | |
<?php if ( x==y ) : ?> | |
<div> | |
Your html | |
</div> | |
<?php else : ?> | |
<div> | |
Your alternative html | |
</div> | |
<?php endif; ?> | |
Alternative method using PHP to echo html | |
<?php if ( x==y ) { | |
echo "<div>"; | |
echo "Your html"; | |
echo "</div>"; | |
} else { | |
... | |
} ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment