簡體   English   中英

從構造函數獲取值到php類中的函數

[英]Get value from constructor to a function in php class

我有一個像這樣的課程:

class List_PendingVerify extends Rs_List {

 public function __construct( $id ) {
           }

    protected function loadData( ) {
           }
}

現在我如何在loadData函數中獲取$ id的值?

這樣我就可以回顯$ id。

謝謝。

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

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

我建議閱讀類和對象文檔。 (特別是,“ 屬性”部分與此處相關。)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM