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

PHP
在PHP中以root身份运行外部命令
PHP编程常用技巧四则
实例学习PHP之投票程序篇
PHP中的加密功能
PHP VS ASP
PHP生成动态WAP页面
PHP中for循环语句的几种变型
PHP5.0对象模型探索之对象串行化
PHP5.0对象模型探索之重载
浅议PHP程序开发中的模板选择
用PHP写的身份证验证程序
PHP.MVC的模板标签系统之初识PHP.MVC
PHP程序加速探索之代码优化
PHP程序加速探索之压缩输出gzip
用PHP文件上传的具体思路及实现
使用PHP编写基于Web的文件管理系统
理解PHP中的MVC编程之控制器
PHP程序加速探索之缓存输出
让你的PHP引擎全速运转的三个绝招
PHP程序加速探索之加速工具软件

在PHP中使用ASP.NET AJAX


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

 

  大功告成!