簡體   English   中英

在控制器Codeigniter中從函數獲取數據

[英]Get data from function to function in controller codeigniter

我是Codeigniter的新手,並且遇到了問題。 您能幫我了解如何從1個控制器中的函數中獲取數據嗎,我嘗試過使用這樣的簡單代碼

public function cow() {
        $first=$this->input->post('name');
}

public function bird() {
    // how to display variable $first = " hello world" in here
}

我希望你能幫助我,:)。

如果這兩個是同一個控制器,則可以使用$this來訪問該函數

public function cow() {
    $first= 'some text';
    return $first; # Add this
}

public function bird() {
   echo  $this->cow();
}

注意:如果要從表單獲取輸入,則無法通過bird函數訪問它

暫無
暫無

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

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