Json文件中的环境变量 [英] Environment Variables in Json file

查看:886
本文介绍了Json文件中的环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在 json 文件中使用系统环境变量?

Can system environment variables be used inside json file?

我的 json 文件如下

{
      "db_host":"localhost",
      "db_user":"root",
      "db_pwd" :"password"
}

目前,我将所有这些值都设置为环境变量。

Currently I set all these values as environment variables.

我可以直接读取json文件中的enironment变量,而不是直接硬编码? >

Can I directly read the enironment variables inside json file, rather than directly hard-coding?

推荐答案

您需要使用PHP读取您的文件,然后调用json_decode将json转换为PHP可以读取的内容。

You need to read your file using PHP and then call json_decode to convert the json into something that PHP can read.

这篇关于Json文件中的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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