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

    1,328 responses to “PHP alternative, lazy syntax”

    1. in this site url why not look here going here additional hints additional resources website link dig this important site view publisher site my sources click for more additional hints click here to investigate find out more Avatar

      Wow that was strange. I just wrote an very long comment but after I clicked submit my comment didn’t appear. Grrrr… well I’m not writing all that over again. Anyhow, just wanted to say wonderful blog!

    2. why not try this out moved here my blog you can find out more go here view it find his comment is here have a peek at this website More... try visit our website learn the facts here now find more info take a look Avatar

      I genuinely enjoy reading on this site, it contains great blog posts. “I have a new philosophy. I’m only going to dread one day at a time.” by Charles M. Schulz.

    3. git.automathon.org Avatar

      References:

      Banque casino fr espace client

      References:
      https://simapodcast.co.ls/@franklyneusebi?page=about

    4. git.freno.me Avatar

      References:

      Rainbow casino wendover

      References:
      https://koseongnam.com/maricruz04x155

    5. chinami.com Avatar

      References:

      Casino barriere

      References:
      https://124.70.144.1/margaretafitzp

    6. ott.saikatinfotech.com Avatar

      References:

      Mexican jumping beans video

      References:
      https://dgwork.co.kr/antoniettay37

    7. www.singuratate.ro Avatar

      References:

      Cherokee casino west siloam springs

      References:
      https://www.howeasynetwork.com/@minniebrock33?page=about

    8. www.sportstvvideo.com Avatar

      References:

      Casino le lyon vert

      References:
      https://git.slegeir.com/alberthagayle

    9. dev-gitlab.dev.sww.com.cn Avatar

      References:

      Fort sill apache casino

      References:
      https://git.dieselor.bg/darwin84819129

    10. wopid.io Avatar

      References:

      Crown casino melbourne

      References:
      https://git.powderbluecrayon.com/lizziearreguin

    11. 创建Binance账户 Avatar

      I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article. https://accounts.binance.info/hu/register-person?ref=IQY5TET4

    Leave a Reply

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