1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title></title> 5 <meta charset="utf-8"/> 6 </head> 7 <body> 8 9 </body> 10 </html> 11 <?php 12 class Site{ 13 var $name; 14 var $url; 15 //构造函数 16 function __construct($name , $url){ 17 $this->name = $name; 18 $this->url = $url; 19 } 20 //析构函数 21 function __destruct(){ 22 echo PHP_EOL . "销毁函数"; 23 } 24 function echoName(){ 25 echo $this->name . PHP_EOL; 26 } 27 28 function echoUrl(){ 29 echo $this->url . PHP_EOL; 30 } 31 } 32 $baidu = new Site('百度' , 'www.baidu.com'); 33 $baidu->echoName(); 34 $baidu->echoUrl(); 35 ?>