php 中 var-export 函数的反义词是什么?
我通过 "var_export($schools,true 将变量导出到文本区域)”以便用户可以编辑它。然后我想用所做的更改来“更新”变量。通过 POST 方法接收更新。
我有一些文本,我想成为变量。我怎样才能做到这一点?
我现在所做的是在 .php 文件中手动编辑变量。我想为用户提供一个网络界面来实现同样的目的。不会有安全问题,因为这只是严格的内部工具。
变量样本
$schools = array(
"PHCS"=> array(
"full_name"=> "Pacific Hills Christian School",
"version"=> "4.0.2b",
"etc"=> "etc"
),
"WAC"=> array(
"full_name"=> "Wollondilly Anglican College",
"version"=> "4.0.1",
"etc"=> "etc"
),
);
I export a variable to a textarea via "var_export($schools,true)" so user can edit it. Then I want to 'update' the variable with the changes made. The updates is received via POST method.
I have some text that I want to become a variable. How can I do that?
What I do right now is that I edit the variable manually in .php file. I want to give an web interface to users do to the same. There won't be no security issues as this will be strictly inhouse tool only.
Sample of the variable
$schools = array(
"PHCS"=> array(
"full_name"=> "Pacific Hills Christian School",
"version"=> "4.0.2b",
"etc"=> "etc"
),
"WAC"=> array(
"full_name"=> "Wollondilly Anglican College",
"version"=> "4.0.1",
"etc"=> "etc"
),
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将考虑使用
eval()
由于安全风险,其使用颇具争议。我建议您使用
serialize()
和 < a href="http://php.net/manual/en/function.serialize.php" rel="nofollow">unserialize()
,或者更好的是 JSON 函数代替。JSON 编码/解码将是向用户显示的最佳选择,因为它具有相当的可读性。
You would be looking at using
eval()
which use of is pretty controversial due to security risks.I would suggest you use
serialize()
andunserialize()
, or even better, the JSON functions instead.The JSON encode/decode would be the best option for displaying to the user as it's fairly readable.
按照 php.net 上的建议,如果您打算更改对象,则应该使用序列化和反序列化:
Following the advice on php.net, if you plan to change the object you should use serialize and unserialize: