0

私は次のようなコントローラーを手に入れました:

class listItems extends CI_Controller{
    private $num;

    public class __construct(){
        parent::__construct();
        $this->num=10;
    }

    public class index(){
        echo $this->num;
    }
}

私がこれをするとき、私は何も得ません。なぜ?

4

1 に答える 1

2

2 つの異なるクラス。同じの下にある必要があるため、function代わりに使用します。

class listItems extends CI_Controller {

    private $num;

    public function __construct() {
        parent::__construct();
        $this->num=10;
    }

    public function index() {
        echo $this->num;
    }

}
于 2012-09-22T23:16:13.553 に答える