Req #45863 [Opn->Csd]: Variable functions.

From: Date: Sun, 02 Nov 2014 01:33:20 +0000
Subject: Req #45863 [Opn->Csd]: Variable functions.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188416@lists.php.net to get a copy of this message
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)

« previous php.bugs (#188416) next »