PHP中JSON的应用

来源:互联网 发布:淘宝买家信用度查询 编辑:程序博客网 时间:2024/05/21 03:24

主调文件index.html

<script type="text/javascript"> function getProfile(str) {      var arr = str;      document.getElementById('nick').innerHTML = arr.nick;  }  </script> <body><div id="nick"></div></body>                 <script type="text/javascript" src="http://www.openphp.cn/demo/profile.php"></script>                               

被调文件profile.php

<?php  $arr = array(      'name' => '陈毅鑫',      'nick' => '深空',      'contact' => array(          'email' => 'shenkong at qq dot com',          'website' => 'http://www.chinaz.com',      )  );  $json_string = json_encode($arr);  echo "getProfile($json_string)";  ?> 


0 0
原创粉丝点击