class Tree {
    public $val;
    public $left;
    public $right;

    public function __construct($element) {
        if (!empty($element)) {
            $this->val = $element;
        }
    }
}

构造一个对象

$s1 = new Tree('1');
$s2 = new Tree('2');
$s3 = new Tree('3');
$s4 = new Tree('4');
$s5 = new Tree('5');
$s3->left = $s4;
$s3->right = $s5;
$s4->left = $s1;
$s4->right = $s2;
var_dump($s3);

构造一个对象

相关文章:

  • 2022-12-23
  • 2021-08-07
  • 2021-11-06
  • 2021-07-25
  • 2022-12-23
  • 2019-09-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2019-09-16
  • 2021-11-28
  • 2022-12-23
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案