Hello Chris,

Wednesday, April 14, 2004, 3:35:05 PM, you wrote:

CdV> I don't understand... how is this:
[snip]
CdV> Better than this?
CdV> =================
CdV> $result = mysql_query ("SELECT * FROM users WHERE id = '".$_GET["id"]."');
CdV> $row_array = mysql_fetch_array ($result);
CdV> $name    = $row_array["name"];
CdV> $address = $row_array["address"];
CdV> $state   = $row_array["state"];
CdV> $include("template.tpl");
CdV> ---
CdV> <html>
CdV> <body>
CdV> Name: <?=$name;?><br>
CdV> Address: <?=$address;?><br>
CdV> State: <?=$state;?><br>
CdV> ...
CdV> =======================

Because you're injecting variables directly into your HTML, which some
of the time might be ok - but what if the $row_array doesn't contain
"name" ? You'll raise an Error Warning without first passing it
through some kind of test (or function).

You assume that the PHP short-tags are enabled (<? ?>) for
echoing variables and while most the time they are, you shouldn't bank
on it in code (incidentally, you don't need the trailing ; on the
short-tag echos).

Sure - these things can be fixed easily, but then that isn't the point
- if you think about it logically, anything Smarty can do, PHP can do
too (well, duh! :)

But what if you want to take your template and perform a bit more than
just mere variable substitution on it? How about highlighting all
words that match a search term, or applying logic to a display block
based on a user status?

Personally I don't use smarty*, but even I can see the benefits it
offers.

* only because I don't build web sites for clients, I build them for
one specific company and we have our own template system in-house.

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to