using data from another function in same class php

there is just kind of pass out for me. i had a procedural code which is working and for some this i try to deploy it in php MVC but i need your help is kind of new to me. pls checkout this my code. and correct. thank you soo much in advance.

 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();
        }

    }

Answers


Use self::FunctionName(); to enter the function from within


I would extract the needed data from $_POST in the constructor of your class and store them using class variables.

class Insert extends Controller {
  var $gender;
  var $ageR;    

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

    $this->gender = $_POST['gender'];
    $this->ageR = explode(',', $_POST['age']);
  }

  function xhrInsert() {           
    $this->model->xhrInsert($this->gender,$this->ageR[0],$this->ageR[1]);
  }

  function getReiseType() {
    $this->model->getReiseType();             

    // Access class properties as you like
    echo $this->gender;
  }
}

Need Your Help

How to update 2D iPhone game to be compatible w/ iPhone 4's retina display?

iphone graphics uiview opengl-es retina-display

What are the necessary steps to update an existing OpenGL ES 1.1 based 2D iPhone game to be compatible w/ the iPhone 4's retina display? I'm still using the Texture2D class that came w/ Apple's

jQuery - If I'm moving a div with the keyboard

javascript jquery html css

If I have a div with a fixed height and width, which I am moving using keypress (or keydown/keyup). Can I get the window to "follow" that div?