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

PHP
PHP新手总结的PHP基础知识
php实现gb2312和unicode间编码转换
用php语言实现数据库连接详细代码介绍
详细解析 PHP 向 MySQL 发送数据过程
利用PHP V5开发多任务应用程序
详细讲解PHP中缓存技术的应用
php escapeshellcmd多字节编码漏洞
《PHP设计模式介绍》导言
《PHP设计模式介绍》第一章 编程惯用法
《PHP设计模式介绍》第二章 值对象模式
《PHP设计模式介绍》第三章 工厂模式
《PHP设计模式介绍》第四章 单件模式
《PHP设计模式介绍》第五章 注册模式
《PHP设计模式介绍》第六章 伪对象模式
《PHP设计模式介绍》第七章 策略模式
《PHP设计模式介绍》第八章 迭代器模式
《PHP设计模式介绍》第九章 观测模式
《PHP设计模式介绍》第十章 规范模式
《PHP设计模式介绍》第十一章 代理模式
《PHP设计模式介绍》第十二章 装饰器模式

在PHP中使用ASP.NET AJAX


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 172 ::
收藏到网摘: 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();

 

  大功告成!