Passing PHP JSON to [removed] echo json_encode vs echo json declaration

后端 未结 9 2258
猫巷女王i
猫巷女王i 2021-01-05 01:52

I\'m trying to create a common constants file to share between php and javascript, using JSON to store the constants. But I\'m wondering why pass the JSON from PHP to javasc

9条回答
  •  庸人自扰
    2021-01-05 02:13

    constant.php

     "val", "const2" => "val2");
    ?>
    
    

    ======================END OF FILE constant.php=======

    In php you can access using

    $array[""]
    

    In javascript, you can access using

    contants.const1, ....
    

提交回复
热议问题