|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-10-26 10:28 UTC] ausvald at tut dot by
Description:
------------
<?
//#1
function test1(){
return __FUNCTION__;
}
echo test1()();
//#2
function test2($var){
return array($var=>$var);
}
echo test2('test')['test'];
?>
Why these things are not implemented in PHP5? And when are they going to be?
Reproduce code:
---------------
<?
//#1
function test1(){
return __FUNCTION__;
}
echo test1()();
//#2
function test2($var){
return array($var=>$var);
}
echo test2('test')['test'];
?>
Why these things are not implemented in PHP5? And when are they going to be?
Expected result:
----------------
<?
//#1
function test1(){
return __FUNCTION__;
}
echo test1()();
//#2
function test2($var){
return array($var=>$var);
}
echo test2('test')['test'];
?>
Why these things are not implemented in PHP5? And when are they going to be?
Actual result:
--------------
Error
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 00:00:01 2025 UTC |
Ok, i thought it's rather easy to understand. #1: $test=test1(); //$test="test1"; echo $test(); // echo "test1"; So why there is no way just to write test()(), which means run variable function that is returned by another function? #2: array($var=>$var) construction means i'm creating an array with 1 element which has key $var and value $var. $test=test2('test'); $test=array('test'=>'test'); echo $test['test']; echo 'test'; So why there is no way just to write echo test2('test')['test'], which means to get an element of array that is returned by a function? Thanks.