Yeah. That's perfectly valid syntax in PHP.superdezign wrote:I could have sworn I've seen this done before...astions wrote:Code: Select all
function some_function($a = array()) { }
argument order
Moderator: General Moderators
- kyberfabrikken
- Forum Commoner
- Posts: 84
- Joined: Tue Jul 20, 2004 10:27 am
- stereofrog
- Forum Contributor
- Posts: 386
- Joined: Mon Dec 04, 2006 6:10 am
Indeed. The language parser allows only "static_scalar"s at this point
http://lxr.php.net/source/ZendEngine2/z ... rser.y#430
but the definition of "static_scalar" quite surprisingly includes arrays as well
http://lxr.php.net/source/ZendEngine2/z ... rser.y#700
"static_scalar" arrays recursively consist of "static scalar"s, so something like this would be also possible (although hardly useful)
http://lxr.php.net/source/ZendEngine2/z ... rser.y#430
but the definition of "static_scalar" quite surprisingly includes arrays as well
http://lxr.php.net/source/ZendEngine2/z ... rser.y#700
"static_scalar" arrays recursively consist of "static scalar"s, so something like this would be also possible (although hardly useful)
Code: Select all
function foo(
$a = array('bar' => array('baz'))
) {