Skip to content

Instantly share code, notes, and snippets.

@NeilJS
Created March 21, 2012 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NeilJS/2146288 to your computer and use it in GitHub Desktop.
Save NeilJS/2146288 to your computer and use it in GitHub Desktop.
PHP if statements
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