Bug #25874 [Com]: var_export does not output valid code

From: Date: Sun, 25 Aug 2013 18:52:18 +0000
Subject: Bug #25874 [Com]: var_export does not output valid code
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-181185@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=25874&edit=1

 ID:                 25874
 Comment by:         paulwolbers at home dot nl
 Reported by:        fire at firepages dot com dot au
 Summary:            var_export does not output valid code
 Status:             Not a bug
 Type:               Bug
 Package:            Variables related
 Operating System:   XP
 PHP Version:        4.3.3
 Block user comment: N
 Private report:     N

 New Comment:

But why is the comma there? I don't want there because it looks like something's wrong
(even if it's correct behaviour)

by the way: you have to check your emailvalidator ... it says my emailaddress is not valid (so now i
used another one)


Previous Comments:
------------------------------------------------------------------------
[2003-10-14 23:04:47] iliaa@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

The trailing comma while unusual is perfectly valid and the code evaluates correctly.

------------------------------------------------------------------------
[2003-10-14 22:21:48] fire at firepages dot com dot au

Description:
------------
output from var_export($var,true) has trailing comma so you have to strip that manually before
utilising the returned string.

the manual example shows this behaviour so perhaps its a feature ?

Reproduce code:
---------------
$yaks = array( 'dfdf'=>'a' , 'b' , 'c' , 'd' )
;
echo '$llama = ' . var_export( $yaks , true ) . ' ;' ;

Expected result:
----------------
$llama = array ( 'dfdf' => 'a', 0 => 'b', 1 => 'c',
2 => 'd' ) ;

Actual result:
--------------
$llama = array ( 'dfdf' => 'a', 0 => 'b', 1 => 'c',
2 => 'd', ) ;


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



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


Thread (5 messages)

« previous php.bugs (#181185) next »