note 36606 modified in function.var-export by aidan
| From: | aidan@php.net | Date: | Wed, 09 Jun 2004 10:48:54 +0000 |
| Subject: | note 36606 modified in function.var-export by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-70621@lists.php.net to get a copy of this message | ||
[john holmes]
True, but that method would require you to open and read the file into a variable and then
unserialize it into another variable.
Using a file created with var_export() could simply be include()'d, which will be less code and
faster.
[kaja]
If you are trying to find a way to temporarily save variables into some other file, check out
serialize() and unserialize() instead - this one is more useful for its readable property, very
handy while debugging.
[original post]
If you're like me, you're wondering why a function that outputs "correct PHP
syntax" is useful. This function can be useful in implementing a cache system. You can
var_export() the array into a variable and write it into a file. Writing a string such as
<?php
$string = '<?php $array = ' . $data . '; ?>';
?>
where $data is the output of var_export() can create a file that can be easily include()d back into
the script to recreate $array.
The raw output of var_export() could also be eval()d to recreate the array.
---John Holmes...
--was--
If you're like me, you're wondering why a function that outputs "correct PHP
syntax" is useful. This function can be useful in implementing a cache system. You can
var_export() the array into a variable and write it into a file. Writing a string such as
<?php
$string = '<?php $array = ' . $data . '; ?>';
?>
where $data is the output of var_export() can create a file that can be easily include()d back into
the script to recreate $array.
The raw output of var_export() could also be eval()d to recreate the array.
---John Holmes...
http://www.php.net/manual/en/function.var-export.php