View Single Post
08-24-2007, 09:48 PM
#13
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

Originally Posted by Haris View Post
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.