如何将var_export的输出读入PHP中的变量?
输出如下在 output.txt 文件中恢复:
the output is like below restored in a output.txt file:
array (
'IMType' => '1',
'Email' => 'test@gmail.com',
'SignupName' => 'test11',
'Password' => '11111',
'Encrypted' => '',
'Confirm' => '11111',
'OldPassword' => '',
'Name' => 'test',
'SignupProvinceText' => 'province',
'SignupCity' => 'cityname',
'Street' => 'street x.y',
'SignupIndustry' => 'IT',
'SignupCompany' => 'jobirn',
'SignupJt' => 'engineer',
'CellPhoneNum' => '',
'linked_in' => '',
)
实际上是var_export(my_variable,true)
的输出,但是如何再次读入变量?
it's in fact output of var_export(my_variable,true)
,but how to read it into a variable again?
推荐答案
像这样:
$dumpStr = var_export($var,true);
eval('$somevar = ' . $dumpStr.';');
相关文章