Php 如何访问其他文件夹中的文件文件\u获取\u内容()
此文件正在运行Php 如何访问其他文件夹中的文件文件\u获取\u内容(),php,json,path,file-get-contents,Php,Json,Path,File Get Contents,此文件正在运行 my-site.com/includes/classes/build/cg.php 它装载 my-site.com/data/data.json 有这样的结构 $data = json_decode(file_get_contents("http://my-site.com/data/data.json"), true); 我想用相关路径加载它,怎么做 尝试了一些组合后,意识到: $data = json_decode(file_get_contents(__DIR__ .
my-site.com/includes/classes/build/cg.php
它装载
my-site.com/data/data.json
有这样的结构
$data = json_decode(file_get_contents("http://my-site.com/data/data.json"), true);
我想用相关路径加载它,怎么做 尝试了一些组合后,意识到:
$data = json_decode(file_get_contents(__DIR__ ."/../../../data/data.json"), true);
或
$data = json_decode(file_get_contents("././././data/data.json"), true);