Home >Backend Development >PHP Tutorial > 类中怎么调生成其它类对象

类中怎么调生成其它类对象

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 12:59:41833browse

类中如何调生成其它类对象
a.php
class a(){}

b.php
class b(){}
a中如何调用b类,并生成对象
public $b=new b();提示Parse error: syntax error, unexpected T_NEW
------解决方案--------------------
在 a 的方法里

class a(){
  public $b;
  function __construct() {
    $this->b = new b;
  }
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn