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

    803 responses to “PHP alternative, lazy syntax”

    1. betterthanthemovieJeowN Avatar

      When the credits roll on your favorite film, pick up this book to keep the feeling alive. Lynn Painter captures the cinematic magic of romance and translates it into prose. A PDF copy ensures that you can dive into Liz and Wes’s world whenever the mood strikes. It is a story that validates your love for grand gestures while showing that the quiet moments are often the most meaningful. https://betterthanthemoviespdf.site/ Better Than The Movies Epub Download​

    2. wutheringheightspdJeowN Avatar

      Teachers often recommend digital texts to help students engage with classic literature. A Wuthering Heights PDF can make the dense Victorian prose more approachable. Many digital readers offer built-in dictionaries, which are invaluable for understanding the dialect and vocabulary used by Brontë. This removes barriers to comprehension and allows the reader to focus on the plot and themes. Whether it is the depiction of the harsh Yorkshire winter or the fiery temperaments of the characters, the digital version makes the text accessible to a new generation of learners. https://wutheringheightspdf.site/ Wuthering Heights Chapter 16 Pdf

    3. prideandprejudicepJeowN Avatar

      For students of the English language, this book is a goldmine. The vocabulary and sentence structure are exemplary. If you are learning English or studying literature, this text is essential. A Pride and Prejudice PDF is a practical study aid. Our website focuses on the educational value of the novel. We provide resources for those looking to master the language through the classics. Improve your English with the help of Jane Austen. https://prideandprejudicepdf.site/ Pride And Prejudice Free Epub

    Leave a Reply

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