zhongbin

<?php
//创建类
class HelloWorld{
//受保护的成员变量
protected $helloWord;
//构造函数 类实例化初始化类成员变量
public function __constructor($helloWord){
$this->helloWord=$helloWord;
}
//类成员方法
public function getHtml(){
retrun "<html><body>This is {$this->helloWord}</body></html>";
}
//释放类成员变量
public function freeResult(){
$this->helloWord=\'\';

}
//析构函数
public function __destructor(){
$this->freeResult();
}
}

//类实例化 创建对象
$test=new HelloWord(\'Hello Word!\');
//对象调用成员方法
$test->getHtml();
$this->freeResult();
?>

 

 

分类:

技术点:

相关文章:

  • 2021-10-18
  • 2021-11-18
  • 2021-11-08
  • 2021-12-04
  • 2021-09-21
  • 2021-12-04
  • 2018-05-23
  • 2021-09-25
猜你喜欢
  • 2021-08-08
  • 2021-12-03
  • 2021-11-17
  • 2021-11-08
  • 2021-08-29
  • 2021-12-04
  • 2021-10-20
相关资源
相似解决方案