Re: Re[2]: [PHP] smarty

From: Date: Wed, 14 Apr 2004 15:57:00 +0000
Subject: Re: Re[2]: [PHP] smarty
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-183337@lists.php.net to get a copy of this message
From: "Richard Davey" <rich@launchcode.co.uk> > 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). Only if you have error_reporting() set high. If you have a PHP templating solution, you'd turn error_reporting() down when you included the PHP templates so you didn't get a warning. > 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). You're relying on web-server writable directories when you use Smarty. It's all a trade-off. > 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? You can do this with output buffering and PHP functions. Smarty just provides you a different interface. <?php start_highlight(); ?> Paragraph Text <?php end_highlight(); ?> vs. {section type="highlight"} Paragraph Text {/section} Yeah, I know that's not quite the Smarty syntax, but you get the idea. Smarty just provides an easy interface to a lot of these things. It's a tool, like a lot of others have said. :) ---John Holmes...

« previous php.general (#183337) next »