Results 1 to 5 of 5

Thread: PHP if

  1. #1
    User
    Join Date
    04-27-10.
    Posts
    134

    Default 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?

  2. #2
    User
    Join Date
    06-19-09.
    Posts
    328

    Default 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.
    Consulenza Contao CMS https://www.intco.it

  3. #3
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: PHP if

    the colon syntax was specifically developed to use in templates, so you don't have to use brackets {}

  4. #4
    User
    Join Date
    07-26-09.
    Posts
    175

    Default Re: PHP if

    I agree with ga.n and thyon. WP plugins creators still use brackets in templates, oh my god :roll:

  5. #5
    User
    Join Date
    04-27-10.
    Posts
    134

    Default Re: PHP if

    Thanks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •