以下代码用了接口,继承。 实现接口,调用静态方法等。仅供参考。
<?php
/**
* Package Desc
* Class
*
* Copyright (C)2007 Dennis
*/
/**
* @ClassName
* @Author
* @LastUpdate
*/
interface IEmployee
{
function GetEmpInfo();
function GetRolePermission();
public static function GetEmpSeqNo();
}// end interface IEmployee
interface IPerson
{
public function GetSex();
}
abstract class Student
{
public abstract function GetEduBg();
}
class Employee implements IEmployee,IPerson
{
private $empId;
private $empName;
private $empSex;
function __construct($empid)
{
$this->empId = $empid;
}
public function EmpId()
{
return $this->empId;
}// end
public function EmpName()
{
return $this->empName;
}
function GetEmpInfo()
{
print "Get Employee Information<br/>";
}// end
function GetRolePermission()
{
print "get role permission()";
}
public static function GetEmpSeqNo()
{
echo "Get Emp Seq No <br/>";
}// end
function GetSex()
{
printf("sex ->{0}","MF");
}
}// end class Employee()
class Manager extends Employee
{
const SEX = 'M';
public static $ss = 100;
function __construct($empid)
{
parent::__construct($empid);
}
function GetManagerTitle()
{
print " get manager title empployee id ->".$this->EmpId();
}//
}// end class Manager()
$employee = new Employee(100);
$employee->GetEmpInfo();
// call static function
Employee::GetEmpSeqNo();
Manager::GetEmpSeqNo();
// call none static function
print "<p> call none static function begin </p>";
Manager::GetEmpInfo();
print "<p> call none static function end </p>";
print Manager::SEX."<br/>";
$mgr = new Manager(200);
$mgr->GetEmpInfo();
$mgr->GetManagerTitle();
print Manager::$ss;
?>