Re: [Text_Highlight] eval() Vs call_user_func()...
| From: | Davey | Date: | Thu, 08 Apr 2004 04:27:20 +0000 |
| Subject: | Re: [Text_Highlight] eval() Vs call_user_func()... | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-27152@lists.php.net to get a copy of this message | ||
Justin Patrin wrote:
Davey wrote:Does not work like this: $func = "Text_Highlight_Php::highlight"; $func($code); - DaveyHey, I've been doing some tests after a comment on using eval() in Text_Highlight I went and modified it to use call_user_func(). Afterwards I decided to benchmark it using Benchmark_Iterate, and have come up with the following surprising results: Using call_user_func(): array(2) { ["mean"]=> string(8) "0.027010" ["iterations"]=> int(1000) } Using eval(): array(2) { ["mean"]=> string(8) "0.026098" ["iterations"]=> int(1000) } Surprising to me. Not enough to cause any reason to choose one over the other.... and I've chosen call_user_func() because I'm from the school of "if eval() is the answer, you're asking the wrong question". - DaveyWhy not use indirection instead? $funcName = 'functionToCall'; $funcName(1, 2, 3);