使用来自同一类php的另一个函数的数据

时间:2016-03-15 12:19:26

标签: php model-view-controller

对我来说只是一种传递。 我有一个程序代码正在工作,对于一些我尝试在php MVC中部署它,但我需要你的帮助对我来说是一种新的。 请查看我的代码。并纠正。 提前谢谢你。

 class Insert extends Controller
    {

         var $gender;
         var $ageR;

         function __construct()
        {
          parent::__construct();  
        }

           function xhrInsert()
        {           
          //  I want to be able to reuse the value of Post in Function below
                $gender = $_POST ['gender'];
                $ageR = explode ( ',', $_POST ['age'] );
                $this->model->xhrInsert($gender,$ageR[0],$ageR[1]);
                }

        function getReiseType()
        {
 // I need the value from $gender in function xhrInsert() here. Because i dont want to $gender = $_POST['gender']; here anymore.

            $this->model->getReiseType();
        }

    }

2 个答案:

答案 0 :(得分:0)

使用self :: FunctionName();从

中输入功能

答案 1 :(得分:0)

我会从类的构造函数中的<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.12.0/moment.js"></script> 中提取所需的数据,并使用类变量存储它们。

$_POST