Page 2 of 2

Posted: Wed Jun 20, 2007 2:46 am
by kyberfabrikken
superdezign wrote:
astions wrote:

Code: Select all

function some_function($a = array())
{

}
I could have sworn I've seen this done before...
Yeah. That's perfectly valid syntax in PHP.

Posted: Wed Jun 20, 2007 3:27 am
by stereofrog
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)

Code: Select all

function foo(
	$a = array('bar' => array('baz'))
) {