php, __construct, post
继承父类的时候 __construct报错误。
w
class a{
   function __construct(){
     $this->post();
   }   function post(){
     //$_POST
    }
}子类b.php
class b extends a{   //默认父类__construct()    functoin index(){
     //
    }
}问题,在用get浏览b.php文件时,能正常浏览,用post提交数据时,报错,
post数据,在注册父类的__construct,或者复写子类的__construct后就正常。。

解决方案 »

  1.   

    测试<form method=post>
    <input type=submit name=submit value=ok>
    </form>
    <?php
    class a{
      function __construct(){
        $this->post();
      }
      function post(){
        print_r($_POST);
      }
    }class b extends a{
      function index(){
      }
    }new b;
    没有发现你说的现象,请检查其他部分
      

  2.   


    我需要的是访问b.php,
    b.php是一个可以浏览的页面。。
    数据操作都在b.php文件里面进行。。
      

  3.   

    通过地址
    http://xxx.com/b.php 来进行访问.class b extends a{
       function index(){
         $date = $this->post();
         $this->view->assign('data', $data);
         $this->view->display('b.html');
       }
    }
      

  4.   

    你的 b 继承于 a,所以b.php需要 include a.php
    这与我写在一起是一样的
      

  5.   


    恩。这个是框架正确访问地址是:http://xxx.com/b/index/所以你的方法不照。