math in smarty
| From: | Monte Ohrt | Date: | Tue, 27 Feb 2001 23:21:00 +0000 |
| Subject: | math in smarty | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-232@lists.php.net to get a copy of this message | ||
We added a way to do math in Smarty. Much easier than mucking with
javascript :-) Should this be included in the default distribution? Does
anyone else have a use for it?
example #1 (simple):
{math equation="x + y" x=5 y=6}
OUTPUT:
11
example #2 (complex):
{math equation="((( height + width ) * total ) / secloop )"
height=$img_height width=$img_width total=#mytotal#
secloop=%mystuff.loop%}
POSSIBLE OUTPUT:
4523
tech note: security checks are made, so things like {math
equation="readfile('/etc/passwd')"} won't work.
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/