Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Aug 032010

Output the parsable string representation of a variable in PHP


var_export allows you to outputs or returns a parsable string representation of a variable.



$a = array (
        "foo" => 1,
        "bar" => 2

echo var_export($a);

It gives:

array (
  'foo' => 1,
  'bar' => 2,

So you can use the output to declare the variable again in another PHP file.

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>