ID:               23022
 Comment by:       kexianbin at diyism dot com
 Reported By:      mfisc...@php.net
 Status:           Open
 Bug Type:         Feature/Change Request
 Operating System: Any
 PHP Version:      5CVS-2003-04-02 (dev)
 New Comment:

When could we realize this in php?

create_function('$v', <<<'fun_code'
echo $v;
fun_code
)('hello');


Previous Comments:
------------------------------------------------------------------------

[2009-02-26 08:20:58] kexianbin at diyism dot com

When could we realize this in php?

create_function('$v', <<<'fun_code'
echo $v;
fun_code
')('hello');

------------------------------------------------------------------------

[2009-02-09 03:13:11] Anatorian at gmail dot com

I think this feature is very important. It can make me happier in php
developing.

------------------------------------------------------------------------

[2009-01-29 01:32:26] jim at akubo dot net

i wish you could use the * operator (like in c++) to derference
references, is there a way todo this in php? instead of writing a new
function like array_val

------------------------------------------------------------------------

[2008-11-25 04:27:37] showmethemoney at google dot com

Guys, we really need this feature to make our code beautiful.

Now:
function get2nd(){
    $tempArray = explode(',', array('a','b','c'));
    return $tempArray[1];
}
Better:
return explode(',', array('a','b','c'))[1];
or:
return array_get(explode(',', array('a','b','c')), '1');

Thanks.

------------------------------------------------------------------------

[2008-11-25 03:28:59] kexianbin at diyism dot com

Developer guys, we php programmers indeed need this function 
to direct access element of the function/method returned array.

Sometimes i work around this so:
echo ${!${''}=&explode(',','a,b,c')}[1];

maybe it's the shortest hack code to mimic direct access,
but it's ugly, we really need to realize it in the php build-in syntax
supporting.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/23022

-- 
Edit this bug report at http://bugs.php.net/?id=23022&edit=1

Reply via email to