本帖最后由 Renyx2 于 2011-04-08 22:41:44 编辑

解决方案 »

  1.   

    <?php
    class foo1
    {
    static public function __construct($x)
    {
    echo($x);
    }
    }class foo2
    {
    public function __construct($y)
    {
    foo1::__construct("world");
    echo($y);
    }
    }$f1=new foo1("hello");
    $f2=new foo2("china");// orclass foo1
    {
    public function __construct($x)
    {
    echo($x);
    }
    }
    class foo2 extends foo1
    {
    public function __construct($y)
    {
    parent::__construct("world");
    echo($y);
    }
    }
      

  2.   

    多谢二楼的回答,但问题并没有解决,有提示了这个错误:
    Fatal error: Constructor foo1::__construct() cannot be static in D:\WEBSITE\Test\objtest.php on line 16
      

  3.   

    你上面的例子是php4上的,那个时候面向对象非常不严格,现在到php5以后,对面向对象使用规范了很多,所以基本上调用对方的构造函数基本上意义不是很大,不如直接用对象的实例!