收藏本页 | 网站地图 | 投稿指南
 
 
当前位置:首页 >> 学院首页 >> 程序开发 >> PHP >>

在PHP中使用ASP.NET AJAX

放大字体  缩小字体  At: 2007-04-26 20:58  By: zxiao_11 转载 来源: 互联网

  编写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();

  大功告成!

  请作者联系本站,及时附注您的姓名。联系邮箱:edu#chinaz.com(把#改为@)。

 






         









 
Google
论坛精华  
网站运营
站长学院
 
 
  ©2005-2008 站长吧 Master8.NET All Rights Reserved 陕ICP备05010609号