如何发送php://输入到页面[重复]

问题描述 投票:-1回答:1

如果我有一个名为lol.json的文件并且其中包含json数据,那么如何使用php将该文件中的数据发送到另一个页面(或同一页面)。

php input protocols inputstream
1个回答
0
投票

这里有一些有用的线你可以使用:

/* Set the json file directory */
$path = 'your path here';
/* here your json file name */
$jsonfile = 'youjsonfilename';
/* json decode */
$language = json_decode(file_get_contents($path . $jsonfile. '.json'));

然后,如果你的json文件看起来像这样:

{
    "test": {
        "test1"                 : "test2",
     }
}

你必须用php写这行来打印“test2”,例如:

<?php echo $language->test->test1; ?>
© www.soinside.com 2019 - 2024. All rights reserved.