Documentation error (register_error())

[email protected] (Pieter Nobels) Wed, 31 Aug 2005 20:42:07 +0200
Newsgroups php.smarty.dev
Message-ID <[email protected]>
I found an error in the documentation of register_function():

http://smarty.php.net/manual/en/api.register.function.php

The example givven (13-1) does not work:

<?php
$smarty->register_function('date_now', 'print_current_date');

function print_current_date($params, &$smarty)
{
   if(empty($params['format'])) {
     $format = "%b %e, %Y";
                                   // PROBLEM:
                                   // Nothing gets returned
   } else {
     $format = $params['format'];
     return strftime($format,time());
   }
}
?>

A correct version would be:

<?php
$smarty->register_function('date_now', 'print_current_date');

function print_current_date($params, &$smarty)
{
   if(empty($params['format'])) {
     $format = "%b %e, %Y";
   } else {
     $format = $params['format'];
   }
   return strftime($format,time());
}
?>

I hope I posted this to the correct mailinglist, I couldn't fine a 
mailinglist specific to the docs. If not, please accept my apologies and 
direct me to the correct mailinglist. Thanks in advance.

-- 
Pieter Nobels