版权声明:本文为博主原创作品,转载请声明出处! https://blog.csdn.net/u011086209/article/details/84966004
/* 获取配置文件url */
function getImagePath($file_url) {
/* 从文件中读取数据到PHP变量 */
$json_string = file_get_contents($file_url);
/* 用参数true把JSON字符串强制转成PHP数组 */
$path = json_decode($json_string, true);
if (!is_array($path)) die("读取配置文件失败!");
/* 打印数据 */
//print_r($path);
return $path["image"]["path"];
}
/* Global配置文件 */
{
"image": {
"path": "D:/workspace/demo/Image/"
},
"other": {
"info": "infomation"
}
}