<?php class Student{ var $name; function __construct(){ echo "I am a Student.<br>"; } function setName($name){ $this->name=$name; } function getName(){ echo "My Name is: ".$this->name."<br>"; } } $lele=new Student(); $lele->setName("LiXingLe"); $lele->getName(); class Teacher extends Student{ function __construct(){ //声明构造函数 parent::__construct();//调用父类的构造函数 echo "I am A Teacher<br>"; } function __destruct(){//声明析构函数 echo "析构函数被执行!"; } } $tea=new Teacher(); ?> <?php class JJiu{ function pJJiu($num){ for ($i=1;$i<=$num;$i++){ for ($j=1;$j<=$i;$j++){ echo $i." X ".$j."= "; echo $i*$j." "; } echo "<br>"; } } } $myJJ=new JJiu(); $myJJ->pJJiu(7); ?>