|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-08-19 10:28 UTC] amethana at gmail dot com
Description:
------------
Variable functions would be nice.
Especially seeing that this works:
class Test {function mb_strlen($v){return mb_strlen($v);}}
$type = 'mb_str';
$obj = new Test;
echo $obj->{$type . "len"}($type);
Reproduce code:
---------------
$type = 'mb_str';
echo {$type . 'len'}($type);
Expected result:
----------------
6
Actual result:
--------------
Parse error: syntax error, unexpected '{' in Command line code on line 1
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 01:00:02 2025 UTC |
Look at this: <?php echo call_user_func('mb_strlen', $type); echo call_user_func_array('mb_strlen', array($type)); ?> You can also do something like this: <?php function MyBrandNewFunction( $Param1, $Param2, $Param3 ){} echo call_user_func('MyBrandNewFunction', $Param1, $Param2, $Param3); echo call_user_func_array('MyBrandNewFunction', array( $Param1, $Param2, $Param3 )); ?> But working like that would be nice too.