Re: 'Pure' php vs 'mixed' (html + php)
| From: | Michael Davey | Date: | Mon, 03 Jun 2002 00:36:49 +0000 |
| Subject: | Re: 'Pure' php vs 'mixed' (html + php) | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-100347@lists.php.net to get a copy of this message | ||
However...
From the point of view of someone who has worked in a company where diesign
is separated from development, it is much better to have separate files with
HTML templates with special markers (in the library I use, it is HTML
comments <!--element_to_replace-->) so that the two processes are adequately
separated.
When all of the HTML is embedded in PHP staements, minor changes to HTML
layout involve a PHP developer, whereas with template based strategies all
they have to do is change the template.
I believe that 'smarty' is the "approved" template libray, but there are
several other worth investigating.
Mikey
"Bogdan Stancescu" <mgv@fx.ro> wrote in message
news:3CFAB54A.7040109@fx.ro...
> No *real* reason - just two not-so-important ones:
>
> 1. Clarity
> Please compare these two:
> ------ "MIXED"
> <td bgcolor="<?php echo $td_col; ?>" class="<?php echo $prefclass;
> ?>">
> <?php $fldcontent=$myrow[0]?$myrow[0]:"no data"; ?>
> <input type="text" name="fname" size="50" value="<?php
> echo $fldcontent;
> ?>">
> </td>
>
> ------ "PURE"
> <?php
> echo("<td bgcolor='$td_col' class='$prefclass'>\n");
> $fldcontent=$myrow[0]?$myrow[0]:"no data";
> echo("<input type='text' name='fname' size='50'
value='$fldcontent'>\n");
> ?>
>
> The second is much easier to read and understand, you must agree.
>
> 2. Speed
> There's an urban legend saying that switching php tags on and off would
> slow parsing down. I don't know if that's true and try to write "pure"
> php as you call it due to the first reason.
>
> Bogdan
>
> Andre Dubuc wrote:
>
> >I've noticed that many people on the list code in 'pure' php, i.e.
> >
> ><?
> >print "<input type='text' name='fname'
> >size='50'>";
> >
> >// etc
> >?>
> >
> >Since most of my code is a mixture (the early stuff is 'mixed' html +
php),
> >I've been wondering why code in 'pure' php? Is there some compelling
reason
> >(that I'm unaware of) for doing so? Should I rewrite all my earlier code
into
> >its 'pure' form? If so, what do I do with the '<! DOCTYPE . . . >
statement
> >-- put it in quotes too?
> >
> >I would like to understand the reasons for writing code in this manner,
when
> >all my code works fine, displays great: am I missing something important
> >here? Btw, I use the 'php' ending for all file names.
> >
> >Your thoughts, opinions and suggestions would be greatly appreciated --
I'd
> >like to do what is best.
> >
> >Tia,
> >Andre
> >
> >
> >
>
>
>