我正在尝试从 php 文件中读取 json 数据。这是我的代码。
category-query.php(这是我的 json 数据)
<script>
var json_data =
[
/*
!please notice
you can add the category name SpecialFeature,
but it will be igone in the main menu
*/
//cat 1
{
"categoryName" : "Dishes",
"categoryImageUrl" : "cat_01.jpg" ,
"categoryRootMenu" : false ,
"categoryStyle" : "one"
},
//cat 2
{
"categoryName" : "Dessert",
"categoryImageUrl" : "cat_02.jpg" ,
"categoryRootMenu" : false ,
"categoryStyle" : "two"
},
//cat 3
{
"categoryName" : "Dimsum",
"categoryImageUrl" : "cat_04.jpg" ,
"categoryRootMenu" : false ,
"categoryStyle" : "submenu"
} ]
这是我在 index .php 上所做的以读取上述值
$get_category = file_get_contents("res3/resproj-data/category-query.php");
$decode = json_decode($get_category);
print $decode;
?>
不幸的是,我无法在$decode
变量中获得这些值,请告诉我如何读取这些值