php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #25993 Lack of functions functionality
Submitted: 2003-10-26 10:28 UTC Modified: 2003-10-27 10:35 UTC
From: ausvald at tut dot by Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: * OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ausvald at tut dot by
New email:
PHP Version: OS:

 

 [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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-26 12:40 UTC] helly@php.net
We don't have $var=>$var, use $var->var.

Besides that noone reading your code will know what you want. For example what is 'test1()();' supposed to do in your oppinion?
 [2003-10-27 04:54 UTC] ausvald at tut dot by
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 00:01:28 2024 UTC