首页 > Web开发 > 详细

PHP 用Class构造JSON数据

时间:2016-04-13 18:59:31      阅读:175      评论:0      收藏:0      [点我收藏+]
header(‘Content-type: appliction/json; charset=shift-JIS‘);
// error
//{
//   "result":  false,
//   "message": "longin",
//   "nextUrl": "http://xxxxx/login/"
// } 
$data =array();
class Test 
{
public $id ;
public $name ;
}

for ($x=1; $x<=50; $x++) {
  $test =new Test();
  $test->id = urlencode("test".strval($x));
  $test->name= urlencode("testname");
  $data[] =$test; 
}

echo "{".‘"result": true, "entrylist"‘.":".urldecode(json_encode($data))."}";

  

PHP 用Class构造JSON数据

原文:http://www.cnblogs.com/zlog/p/5388118.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!