I am trying to learn OO PHP. I get really confused looking at the code. I don't understand what detremine that we will use $this or not.
Like in the codde below.
if(($check_stage<=$called_stage)&&(!$errors_detected))
{
$this->model[$check_stage]->check_required_fields();
/**
* Check if any errors are loaded into the rf_error_codes array
*/
if(count($this->model[$check_stage]->rf_error_codes))
{
$this->errors = array_merge($this->errors,$this->model[$check_stage]->rf_error_codes);
/**
* Validation errors were detected for this model, we want to send the user to this
* step.
*/
$this->stage = $check_stage;
/**
* Set the errors detected flag, so we won't save the data or increment the stage
* counter. However, we want to continue looping and and building data for each model,
* so that to the user it will appear we're saving their data. When they return to the page
* the fields will be pre-filled with anything they've filled out so far.
*/
$errors_detected = true;
}
why not use $this in first if statment , like below.
if(($this->check_stage<=$called_stage)&&(!$errors_detected))
on what bases they decided not to us $this.
same way what made them decide use
$this->stage = $check_stage; not $stage = $check_stage;
and use
$errors_detected = true; NOT $this->errors_detected = true;
Like in the codde below.
if(($check_stage<=$called_stage)&&(!$errors_detected))
{
$this->model[$check_stage]->check_required_fields();
/**
* Check if any errors are loaded into the rf_error_codes array
*/
if(count($this->model[$check_stage]->rf_error_codes))
{
$this->errors = array_merge($this->errors,$this->model[$check_stage]->rf_error_codes);
/**
* Validation errors were detected for this model, we want to send the user to this
* step.
*/
$this->stage = $check_stage;
/**
* Set the errors detected flag, so we won't save the data or increment the stage
* counter. However, we want to continue looping and and building data for each model,
* so that to the user it will appear we're saving their data. When they return to the page
* the fields will be pre-filled with anything they've filled out so far.
*/
$errors_detected = true;
}
why not use $this in first if statment , like below.
if(($this->check_stage<=$called_stage)&&(!$errors_detected))
on what bases they decided not to us $this.
same way what made them decide use
$this->stage = $check_stage; not $stage = $check_stage;
and use
$errors_detected = true; NOT $this->errors_detected = true;