Re: smarty
| From: | Chris de Vidal | Date: | Wed, 14 Apr 2004 14:35:05 +0000 |
| Subject: | Re: smarty | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-183323@lists.php.net to get a copy of this message | ||
Vicente Werner said:
> >
> > http://marc.theaimsgroup.com/?l=php-general&m=108145205519710&w=2
> Ugh that's not just fuckingly ugly, but a total doom to maintain over the
> time -two months without touching the code and you're absolutely lost- .
> It maybe faster, it maybe a bit simpler since you only have to learn one
> language, but it's a mental carnage to maintain a client site that way....
I don't understand... how is this:
==================================
$page = new Smarty();
$result = mysql_query ("SELECT * FROM users WHERE id =
'".$_GET["id"]."');
$row_array = mysql_fetch_array ($result);
$page->assign("name", $row_array["name"]);
$page->assign("address", $row_array["address"]);
$page->assign("state", $row_array["state"]);
$page->display("template.tpl");
---
<html>
<body>
Name: {$name}<br>
Address: {$address}<br>
State: {$state}<br>
...
===================
Better than this?
=================
$result = mysql_query ("SELECT * FROM users WHERE id =
'".$_GET["id"]."');
$row_array = mysql_fetch_array ($result);
$name = $row_array["name"];
$address = $row_array["address"];
$state = $row_array["state"];
$include("template.tpl");
---
<html>
<body>
Name: <?=$name;?><br>
Address: <?=$address;?><br>
State: <?=$state;?><br>
...
=======================
They both look about the same (well in the native PHP example I actually
wrote less code).
Perhaps you were looking at my spaghetti-code example, but take another
look, I posted 3 examples.
/dev/idal