Re: [SMARTY-DEV] create_function strange behaviour
| From: | Monte Ohrt | Date: | Mon, 10 Jun 2002 22:07:58 +0000 |
| Subject: | Re: [SMARTY-DEV] create_function strange behaviour | ||
| References: | 1 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-135@lists.php.net to get a copy of this message | ||
Does $a have a value? Evaluated strings should be used in double quotes: "$a", so I'm not sure what trouble '$a' would cause.
Bram van Leur wrote:
This is probably not a real Smarty bug, but I can only reproduce it's strange behaviour with Smarty using the following piece of code: <?php require 'Smarty.class.php'; $smarty = new Smarty; $smarty->force_compile = true; $smarty->register_prefilter(create_function('$a', 'return $a;')); $smarty->display('a.tpl'); $smarty->display('b.tpl'); print_r($smarty->_plugins['prefilter']); ?> It gives (with any Smarty 2.* version) an error about calling an function without a name. The a and b template just contain one word (like foo and bar). After an hour of hunting this bug I found out that the _plugins['prefilter'] contains the following: [] => Array('lambda_1', null, null, false) This is quite strange because of the differing key and function name (as first element in the Array). Looking at register_prefilter shows me they are both set using the $function parameter. How can they differ? Next load_plugin messes it up by setting a true to the wrong (new) entry. A second run on the same smarty object makes it real fun because of a fake (and loaded) plug-in entry. Anyway, the thing that causes the trouble is the strange return of create_function. Can anyone tell me why the $function variable in register_prefilter has a different value the 2 times its used in the same statement?-- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.