开发者

Get value from constructor to a function in php class

开发者 https://www.devze.com 2022-12-19 10:05 出处:网络
i have a class like: class List_PendingVerify extends Rs_List { public function __construct( $id ) { } protected function loadData( ) {

i have a class like:

class List_PendingVerify extends Rs_List {

 public function __construct( $id ) {
           }

    protected function loadData( ) {
           }
}

Now i how co开发者_JAVA百科uld i get value of $id in loadData function ?

so that i can be able to echo $id.

Thanks.


class List_PendingVerify extends Rs_List {
    public function __construct($id) {
        $this->id = $id;
    }

    protected function loadData() {
        echo $this->id;
    }
}

I recommend reading the Classes and Objects documentation. (In particular, the Properties section is relevant here.)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号