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

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

WBOY
Release: 2016-06-13 12:59:41
Original
796 people have browsed it

类中如何调生成其它类对象
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;
  }
}

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template