To pass value of a variable in one function to another function in same class

前端 未结 2 1824
情书的邮戳
情书的邮戳 2021-01-28 19:19

I have a class Block_Model (actually a model in Kohana framework) with 2 methods input()and output().

class Block_Model e         


        
2条回答
  •  死守一世寂寞
    2021-01-28 20:05

    You'll need private property:

    class Something{
       private $_variable = "";
    
       function input( $data ){
          $this->_variable = $data;
          //do the rest of function
       }
    
       function output(  ){
          //get previously set data
          echo $this->_variable;
       }
    
    }
    

提交回复
热议问题