Skip to content

Instantly share code, notes, and snippets.

@tonijz
Last active December 28, 2015 05:39
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 tonijz/7451578 to your computer and use it in GitHub Desktop.
Save tonijz/7451578 to your computer and use it in GitHub Desktop.
// BAD
// Hard to read because of php syntax everywhere... If whole file will be written like this,
// It gonna take a lot of time for others to understand
<tr>
<td>
<?php if($c['status'] == "Live") { ?>
<span class="label label-success">
<?php } else { ?>
<span class="label label-warning">
<?php } ?>
<?php echo $c['status']; ?>
</span>
</td>
// BETTER
// In templates u should use alternative php syntax, there will be none of those anoying brackets {}
// looks much better IMO
<tr>
<td>
<?php if($c['status'] == 'Live'): ?>
<span class="label label-success">
<?php else: ?>
<span class="label label-warning">
<?php endif; ?>
<?php echo $c['status']; ?>
</span>
</td>
// PROPPER
// Takes just one line :)
// Easy to read
<tr>
<td>
<span class="label<?php echo ($c['status'] == 'Live') ? ' label-success' : ' label-warning' ; ?>">
<?php echo $c['status']; ?>
</span>
</td>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment