Am 20.09.2010 20:56, schrieb Andy McKenzie:
Hey folks,

   I have the feeling this is a stupid question, but I can't even find
anything about it.  Maybe I'm just not searching for the right things.

   Here's the problem.  I'm writing a lot of pages, and I hate going in
and out of PHP.  At the same time, I want my HTML to be legible.  When
you look at it, that's kind of a problem, though... for instance
(assume this had some PHP in the middle, and there was actually a
reason not to just put this in HTML in the first place):

Simple PHP:

echo '<html>';
echo '<head>';
echo '<title>Page Title</title>';
echo '</head>';
echo '<body>';
echo '<p>This is the page body</p>';
echo '</body>';
echo '</html>';


Output page source:
<html><head>   <title>Page Title</title></head><body><p>This is the
page body</p></body></html>

Now, I can go through and add a newline to the end of each line (echo
'<html>' . "\n"; and so on), but it adds a lot of typing.  Is there a
way to make this happen automatically?  I thought about just building
a simple function, but I run into problem with quotes -- either I
can't use single quotes, or I can't use double quotes.  Historically,
I've dealt with the issue by just having ugly output code, but I'd
like to stop doing that.  How do other people deal with this?

Hi Alex,
yes you can build a lot of classes to build the html you want and produce elegant and clean code. But, the job to do that is enorm, and sincerly i dont know what is better.

You can use some templating system like Zend Framwork and if not possible consider to use str_replace() to "parse" your Template and replace the variables in there. You can use a token like ###VAR_NAME### to address a variable like $var_name or something like this.



PHP General Mailing List (
To unsubscribe, visit:

Reply via email to