PHP alternative, lazy syntax

Alternative, lazy what?

Consider the next example:

';
     echo ''.$oItem->title.'';
     echo '';
} ?>

We could write the above like this:


     
  • title?>
  • Personally I think the second example is much easier to understand and a lot clearer for someone who isn’t familiar with PHP then the second one. (unfortunately my code highlight plugin thinks different though 😉 ) No braces in the code will also prevent some people to get the idea it’s to difficult to use PHP inside HTML and that integrating PHP into HTML is a task for PHP developers only. Also notice the advantage when indenting the HTML code.
    Futher it helps me to distinguish in my own projects template files and controllers, models,… because of the different syntax. So when I have a a file with mixed PHP and HTML this is the preferred way for me.

    Great! Let’s start using it!
    Good idea but bear in mind that their are a few drawbacks:

    • Not all servers allow the shorttags (check the short_open_tag entry in your php.ini file)
    • Not using ; in the above example is a bad practice and should be avoided
    • The most important one, their are other template engines on the market like Smarty, Dwoo, Savant, Template Blocks and a lot more that do the same thing but then easier or better (although you have minimal overhead)

    Futher I should note their are some heavy discussions (still?) going on in the PHP community whether the short tags are genius or just plain evil. One thing is pretty sure now the short tags will still be available in PHP version 6.

    For the complete list of the alternative syntax visit php.net

    Please fill in the poll and leave a comment.

    Comments

    967 responses to “PHP alternative, lazy syntax”

    1. www.herzog-it.de Avatar

      References:

      What is an anabolic steroid

      References:
      https://musixx.smart-und-nett.de/jamesdeering49

    2. 221.226.114.142 Avatar

      References:

      How much does a cycle of steroids cost

      References:
      http://106.55.174.214:3000/alvin10x146958

    3. http://182.92.251.55/ Avatar

      References:

      How long does it take for winstrol to work

      References:
      http://repo.magicbane.com/jessneale77737

    4. git.htns.com Avatar

      References:

      Best stack for cutting fat and gaining muscle

      References:
      http://175.27.229.211:3000/doylemarian509

    5. 117.102.231.130 Avatar

      References:

      Muscle steroids for sale

      References:
      http://49.233.105.190:3000/kandiceeggers

    6. http://120.76.251.151:3000/moiseshardin1 Avatar

      References:

      Female bodybuilding steroids side effects

      References:
      http://www.mikarsoft.com/rachaelpendley

    7. 103.119.85.197 Avatar

      References:

      Bad things about steroids

      References:
      http://106.55.0.66:31807/willianzapata3

    8. http://121.41.2.71/ Avatar

      References:

      Best gnc supplements to get ripped

      References:
      http://81.69.221.216:3000/daniellerapp2

    9. www.ikaros.asia Avatar

      References:

      Alcohol and prednisone

      References:
      http://dev-gitlab.dev.sww.com.cn/tillybobb62728

    10. webpage Avatar

      Wow, this piece of writing is good, my younger sister is analyzing these kinds of things, thus I
      am going to convey her.

    Leave a Reply

    Your email address will not be published. Required fields are marked *