RSS订阅
用户名: 密码:

在PHP中使用ASP.NET AJAX

2007-03-17 10:06:04 作者:探索者 来源: 浏览次数:0 网友评论 0

<strong>编写Service文件</strong> <br /><br />新建一个php文件,命名为EmployeeService.php。首先写上这一句,include必要的支持代码: <br /><br />require_once 'MSAjaxService.php'; <br /><br /><br />然后定义一个Employee类。四个属性一目了然,不用多说: <br /><br />class Employee <br />{ <br />public $Id; <br />pub
编写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();


大功告成!


相关文章

[错误报告] [推荐] [收藏] [打印] [关闭] [返回顶部]

最新图片文章

最新文章


关于本站帮助(?)┊广告服务版权声明业务合作加盟我们网站地图联系我们
Copyright © 2005-2008 www.phpip.com online services. All rights reserved. 陕ICP备05002402号
在线管理员 QQ:271162318 17864997