Originally Posted by Haris
How do you get conditional statements between classes(functions)?
Example:
PHP Code:
public function oneYearPasses(){
$TheHeight = $this->_Height++;
$return_val = 'The '.$this->_Type.' Tree grows to '.$TheHeight.' meter <br/>';
return $return_val;
if($TheHeight == 10){
$return_val = '<b>Your Tree is now mature and grows 10 fruits</b>';
return $return_val;
$this->_Fruit = 10;
}
}
The if statement doesn't return the value when reaches to 10 meters.
|
This is because you arent calling the variables correctly, its $this->variable, not $this->_variable
edit:
Plus the if statement will never be executed because
PHP Code:
return $return_val;
is not in a conditional statement, therefore no code below it will run.