php中var-export函数的反面是什么? [英] What's the opposite of var-export function in php?

查看:20
本文介绍了php中var-export函数的反面是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过 "var_export($学校,真实)",因此用户可以对其进行编辑.然后我想用所做的更改更新"变量.通过 POST 方法接收更新.

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?

我现在所做的是在 .php 文件中手动编辑变量.我想为用户提供一个 Web 界面.不会有任何安全问题,因为这将是严格的内部工具.

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.

变量样本

$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"
      ),
  );

推荐答案

您可能会考虑使用 eval() 由于安全风险,它的使用非常有争议.

You would be looking at using eval() which use of is pretty controversial due to security risks.

我建议你使用 serialize()unserialize(),甚至更好,JSON 函数.

I would suggest you use serialize() and unserialize(), or even better, the JSON functions instead.

JSON 编码/解码将是向用户显示的最佳选择,因为它具有相当的可读性.

The JSON encode/decode would be the best option for displaying to the user as it's fairly readable.

这篇关于php中var-export函数的反面是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆