mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-11 21:12:15 +09:00
Add option to skip serialization when saving PHP data to file
This commit is contained in:
parent
c7f84a4dfe
commit
f416b7c8a4
1 changed files with 11 additions and 2 deletions
|
|
@ -356,15 +356,24 @@ class Storage
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @param mixed $data
|
* @param mixed $data
|
||||||
* @param string $comment (optional)
|
* @param string $comment (optional)
|
||||||
|
* @param bool $serialize (optional)
|
||||||
* @return string|false
|
* @return string|false
|
||||||
*/
|
*/
|
||||||
public static function writePHPData($filename, $data, $comment = null)
|
public static function writePHPData($filename, $data, $comment = null, $serialize = true)
|
||||||
{
|
{
|
||||||
if ($comment !== null)
|
if ($comment !== null)
|
||||||
{
|
{
|
||||||
$comment = "/* $comment */\n";
|
$comment = "/* $comment */\n";
|
||||||
}
|
}
|
||||||
return self::write($filename, '<' . '?php ' . $comment . 'return unserialize(' . var_export(serialize($data), true) . ');');
|
if ($serialize)
|
||||||
|
{
|
||||||
|
$content = '<' . '?php ' . $comment . 'return unserialize(' . var_export(serialize($data), true) . ');';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$content = '<' . '?php ' . $comment . 'return ' . var_export($data, true) . ';';
|
||||||
|
}
|
||||||
|
return self::write($filename, $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue