Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

O'Reilly:
Here and There with Heredoc
Apr 11, 2003 @ 12:12:04

Tired of having PHP, HTML, and even SQL jumbled together in the same file? Are your designers, coders, and DBAs going crazy trying to keep everything in check? A clean layer of separation can help. Daniel Smith explains how PHP's heredocs can make your life much easier by separating presentation, content, and logic.

In this new article from the O'Reilly Network, "PHP and Heredocs", they show you how to use the heredoc syntax in PHP to create a separation between the heart of your code and the HTML or multi-line SQL that it needs. Think about it - remove the hard-coded HTML from your PHP functions, place it in a templated file, and just call it when you need it. Voila! Separation of content and layout (the way it should be).

They do give you a good idea of how to use this syntax, and even give some pretty good examples for you to base the templating system off of. It's not the most efficient way to do it, but it gets the job done...

tagged:

Link:


Trending Topics: