当前位置: 首页 > 图文教程 > 网络编程 > PHP > 在PHP中使用ASP.NET AJAX

PHP
MySQL安全性指南
长沙发上的对话(一)
长沙发上的对话(二)
长沙发上的对话(三)
长沙发上的对话(四)
《PHP程序设计》序
《PHP程序设计》第一章 什么是PHP?
PHP4的新特征
php3的ODBC函数
初学入门 PHP 和 MySQL
《PHP程序设计》 第二章 安装PHP
《PHP程序设计》 第三章 PHP中的数据处理
《PHP程序设计》 第四章 程序控制
《PHP程序设计》 第五章 中场一:数据库连接
PHP4中的SESSION管理
开发大型PHP项目的方法(一)
开发大型PHP项目的方法(二)
开发大型PHP项目的方法(三)
开发大型PHP项目的方法(四)
开发大型PHP项目的方法(五)

在PHP中使用ASP.NET AJAX


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 106 ::
收藏到网摘: n/a

  编写Service文件


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

 

  然后定义一个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", "[email protected]", 1000);
}
}

 

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

以下为引用的内容:
$theService = new EmployeeService();
$theService->ProcessRequest();

 

  大功告成!