ID: 16074 Updated by: [EMAIL PROTECTED] -Summary: CVS function var_export() can't handle recursive arrays Reported By: [EMAIL PROTECTED] -Status: Open +Status: Bogus Bug Type: Variables related Operating System: RH 7.1 PHP Version: 4.0CVS-2002-03-14 New Comment:
var_export() isn't meant for recursive structures, fixing this makes no sense. Derick Previous Comments: ------------------------------------------------------------------------ [2002-03-14 10:39:24] [EMAIL PROTECTED] The problem is similar to var_dump(). var_dump() is fixed by Yasuo today but another one raised (see Bug#16065) var_export() has to handle recursive dependencies better and the fatal error is not an option. Here is the script: <?php $a=array(); $a[]=&$a; var_export($a); ?> and the ouput: bash-2.04$ ../php export.php X-Powered-By: PHP/4.3.0-dev Content-type: text/html array ( 0 => array ( 0 => array ( 0 => array ( PHP Fatal error: Nesting level too deep - recursive dependency? in /usr/samba/users/andy/412dev/php4-200203140300/te/export.php on line 4 <br /> <b>Fatal error</b>: Nesting level too deep - recursive dependency? in <b>/usr/samba/users/andy/412dev/php4-200203140300/te/export.php</b> on line <b>4</b><br /> Possible fix is another parameter(string) with var_export()-ed variable name - this will fix if the array has element which is reference to the array but will not handle this : <?php $a=array(1,2); $a[]=&$a; $b=array(&$a,3,4); var_export($a); ?> that crashes with output : array ( 0 => 1, 1 => 2, 2 => array ( 0 => 1, 1 => 2, 2 => array ( 0 => 1, 1 => 2, 2 => array ( 0 => 1, 1 => 2, 2 => array ( PHP Fatal error: Nesting level too deep - recursive dependency? in /usr/samba/users/andy/412dev/php4-200203140300/te/export.php on line 6 <br /> <b>Fatal error</b>: Nesting level too deep - recursive dependency? in <b>/usr/samba/users/andy/412dev/php4-200203140300/te/export.php</b> on line <b>6</b><br /> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16074&edit=1