-
PHP if
Evening
I've only touched the surface when it comes to php.
When ever I've done an if function I've always done it like so..
Code:
<?php if (blblbl) { ?>
<div>template stuff</div>
<?php } ?>
I noticed in the templates that all if functions are written like..
Code:
<?php if (blablabla) : ?>
<div>template stuff</div>
<?php endif; ?>
Can someone explain the differences between the 2 and if there is an advantage of using one over the other?
-
Re: PHP if
Read this: http://php.net/manual/en/control-str...ive-syntax.php
There's no difference, it is a matter of "tastes".
I prefer the syntax with the colon because I think is more readable, especially if you have nested statements.
-
Re: PHP if
the colon syntax was specifically developed to use in templates, so you don't have to use brackets {}
-
Re: PHP if
I agree with ga.n and thyon. WP plugins creators still use brackets in templates, oh my god :roll:
-
Re: PHP if