在PHP中使用ASP.NET AJAX

时间:2008-12-15 10:09:18   来源:第二电脑网上收集  作者:

  第二电脑网导读:说: class Employee { public $Id; public $Name; public $Email; public $Salary; function __construct($id, $name, $email, $salary) { $this->Id = $id; $this->Name = $name; $this->Email = $email; $this->Salary= $salary; } } 接下来是Emplo...
  正文:编写Service文件

新建一个PHP文件,命名为EmployeeService.php。首先写上这一句,include必要的支持代码

require_once 'MSAjaxService.php';


然后定义一个Employee类。四个属性一目了然,不用多说:

class Employee
{
public $Id;
public $Name;
public $Email;
public $Salary;

function __construct($id, $name, $email, $salary)
{
$this->Id = $id;
$this->Name = $name;
$this->Email = $email;
$this->Salary= $salary;
}
}


接下来是EmployeeService类,继承与MSAjaxService.php中的MSAjaxService基类。其中定义一个方法,用来返回一个Employee对象:

class EmployeeService extends MSAjaxService
{
function GetEmployee()
{
return new Employee(12345, "Dflying Chen", "Dflying@some.com", 1000);
}
}


然后新建一个EmployeeService的实例,并且调用基类的ProcessRequest()方法,处理该请求:

$theService = new EmployeeService();
$theService->ProcessRequest();


大功告成!

来源:http://www.002pc.com/master/College/Programming/PHP/2008-11-27/4032.html

收藏到:

关于《在PHP中使用ASP.NET AJAX》文章的评论

共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面

随机文章

    SQL Error: select * from ***_ecms_article where classid='86' and checked=1 order by rand() limit 10

顶出来的热门

    SQL Error: select * from ***_ecms_article where classid='86' and checked=1 order by diggtop desc,id desc limit 10
站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td