Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1984 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

OOP for a PHP Newbie

Thread title: OOP for a PHP Newbie
Closed Thread    
    Thread tools Search this thread Display Modes  
08-24-2007, 09:48 PM
#1
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.

08-24-2007, 10:18 PM
#2
Haris is offline Haris
Status: Request a custom title
Join date: Dec 2005
Location:
Expertise:
Software:
 
Posts: 2,741
iTrader: 9 / 100%
 

Haris is on a distinguished road

  Old

Originally Posted by Village Idiot View Post
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.
Thanks Village.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed