Req #45863 [Opn->Csd]: Variable functions.
Edit report at https://bugs.php.net/bug.php?id=45863&edit=1
ID: 45863
Updated by: requinix@php.net
Reported by: amethana at gmail dot com
Summary: Variable functions.
-Status: Open
+Status: Closed
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: Irrelevant
PHP Version: 5.2.6
-Assigned To:
+Assigned To: requinix
Block user comment: N
Private report: N
New Comment:
Supported in PHP 7.
http://3v4l.org/mGOCD
Previous Comments:
------------------------------------------------------------------------
[2012-10-12 20:17:52] klaussantana at gmail dot com
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.
------------------------------------------------------------------------
[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
Thread (3 messages)