a.php
class a(){}b.php
class b(){}
a中如何调用b类,并生成对象
public $b=new b();提示Parse error: syntax error, unexpected T_NEW

解决方案 »

  1.   

    在 a 的方法里class a(){
      public $b;
      function __construct() {
        $this->b = new b;
      }
    }
      

  2.   

    在调用页面,注意写一个 autoloadfunction __autoload($classname)
    {
      switch($classname){
           case "a" : requre_once("a.php"); break;        case "b" : requre_once("b.php"); break;
           default : xxxx  break;
      }}
    这样就不用乱折腾,到处写require 了~
      

  3.   

    照改了,但是这么写$this->wsql->query,出现错误Fatal error: Using $this when not in object context in 
      

  4.   

    在你已贴出的代码中,没有看到 wsql 字样
    我也不能无中生有吧?