当前位置: 首页 > 图文教程 > 网络编程 > PHP > 在PHP中使用ASP.NET AJAX
编写Service文件
新建一个php文件,命名为EmployeeService.php。首先写上这一句,include必要的支持代码:
然后定义一个Employee类。四个属性一目了然,不用多说:
| 以下为引用的内容: function __construct($id, $name, $email, $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(); |
大功告成!
评论 (0) All