PHP __destruct公共变量

时间:2019-01-24 17:18:26

标签: php function class variables global-variables

如何使用这种方式。我想用最近运行的函数创建一个全局变量。

<?php
class test{
    public $number = null;
    public function __destruct(){
      $this->number = 5;
    }
}
$test = new test();
echo $test->number; // null
// How can I use this way.
?>

0 个答案:

没有答案