Re: mixing HTML and PHP code

From: Date: Fri, 12 Jan 2001 19:08:17 +0000
Subject: Re: mixing HTML and PHP code
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-34283@lists.php.net to get a copy of this message
Alex Black wrote: > > <input type="text" name="hello" size="20" > > value="{value}"> > > and the problem with that, is you're not paring tons of html through a > search-replace function, which also created unnecessary overheead, and You have a point here. Template-systems are slow. > forces you (once again) to make a spec that says "here's how this template > system works) There are "standard"-template-systems like FastTemplates or PHPLIB templates. > part of the point was for _PHP_ to be embedded html, in my opinion your It was created that way. It still is possible. Is can be quite handy, sometimes (or often, depends on what you do). That doesn't mean you have to use it. > example above takes the "don't mix logic with markup" much too far: I don't think I crossed a border here. When execution-speed doesn't matter that much (wich often is the case), there is only one rule: Get it done as fast and reusable as possible. Code that uses templates tends to be very reusable, at least it is VERY easy to change the design. And if the design is done by a designer who doesn't know PHP, it may also be done faster. > <input type="text" name="hello" size="20" > value="<?=$value?>"> > > is really not that much harder to write. With a HTML-editor? It probably would HTML-encode this, so you end up with &lt;=$value&gt; > html people can ignore it, almost > php can find their code, and those that know > both can reap the benefits. > > what about loops? Templates can do loops, with so called "blocks". Your system can't. Not whithout mixing PHP and HTML in a way that will make a designer throw hardware at you. > etc... > > you start building your own little template language constructs, which is > dumb because php already has them! There are clean (but slow) template-solutions out there. Maybe this will change some day. Anyway, from a designers point of view, your system is far messier (especially with loops) than templates. But faster, both for you to write and to execute for PHP. Well, this is a world of tradeoffs. Wagner -- One maniac alone can do what 20 together cannot

« previous php.general (#34283) next »