Edit report at https://bugs.php.net/bug.php?id=45863&edit=1
ID: 45863
Comment by: klaussantana at gmail dot com
Reported by: amethana at gmail dot com
Summary: Variable functions.
Status: Open
Type: Feature/Change Request
Package: Feature/Change Request
Operating System: Irrelevant
PHP Version: 5.2.6
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2008-08-19 10:28:11] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=45863&edit=1