编写Service文件
新建一个php文件,命名为EmployeeService.php。首先写上这一句,include必要的支持代码: 中.国.站长站
| 以下为引用的内容: require_once ''MSAjaxService.php''; |
站长.站
然后定义一个Employee类。四个属性一目了然,不用多说:
中.国站长站
| 以下为引用的内容: function __construct($id, $name, $email, $salary) |
中国.站长站
接下来是EmployeeService类,继承与MSAjaxService.php中的MSAjaxService基类。其中定义一个方法,用来返回一个Employee对象: Chinaz@com
| 以下为引用的内容: class EmployeeService extends MSAjaxService { function GetEmployee() { return new Employee(12345, "Dflying Chen", "Dflying@some.com", 1000); } } |
Chinaz~com
Chinaz@com
然后新建一个EmployeeService的实例,并且调用基类的ProcessRequest()方法,处理该请求:
中国站长_站,为中文网站提供动力
| 以下为引用的内容: $theService = new EmployeeService(); $theService->ProcessRequest(); |
中国站.长.站
站.长站
大功告成! Www~Chinaz~com
请作者联系本站,及时附注您的姓名。联系邮箱:edu#chinaz.com(把#改为@)。 [中国站长站]
