[PHPTAL] a little bug

Tjerk Meesters tjerk.meesters at gmail.com
Wed May 17 04:00:52 CEST 2006


In my opinion, this should be fixed on a higher level: in your own
programming code:

if (isset($cmd)) {
  $tpl->set($cmd,'world');
}

It's perfectly okay for the context setter to assume the passed name
actually exists; adding this would be excess baggage for 99.9% of the
cases.


Cheers,
  Jack

On 5/16/06, mlists at c-net.it <mlists at c-net.it> wrote:
> just an example run this code
>
> $cmd = 'hello';
> unset($cmd)
>
> $tpl->set($cmd, 'world');
>
>
> how to fix it
>
>     /**
>      * Context setter.
>      */
>     public function __set($varname, $value)
>     {
> /* workaround */
> if ( !isset($varname) )
> return
> /* workaround */
>
>         if ($varname[0] == '_'){
>             $e = 'Template variable error \'%s\' must not begin with underscore';
>             $e = sprintf($e, $varname);
>             throw new Exception($e);
>         }
>         $this->$varname = $value;
>     }
>
>
>
> _______________________________________________
> PHPTAL mailing list
> PHPTAL at lists.motion-twin.com
> http://lists.motion-twin.com/mailman/listinfo/phptal
>


-- 
--
Tjerk



More information about the PHPTAL mailing list