PHP 用Class构造JSON数据

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))."}";

  

上一篇:C#学习笔记四: C#3.0自动属性&匿名属性及扩展方法


下一篇:成为java高手的成长历程想学好java必看