|
|
|
|
Thread title: OOP for a PHP Newbie |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
08-24-2007, 09:38 PM
|
#11
|
Status: Junior Member
Join date: Jul 2007
Location:
Expertise:
Software:
Posts: 43
|
haris' reply was deleted.
|
|
08-24-2007, 09:44 PM
|
#12
|
Status: Request a custom title
Join date: Dec 2005
Location:
Expertise:
Software:
Posts: 2,741
|
Sorry for the confusion. Please re-read my post.
|
|
08-24-2007, 09:48 PM
|
#13
|
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
Posts: 6,894
|
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.
|
|
08-24-2007, 10:18 PM
|
#14
|
Status: Request a custom title
Join date: Dec 2005
Location:
Expertise:
Software:
Posts: 2,741
|
Originally Posted by Village Idiot
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.
|
|
08-25-2007, 12:11 AM
|
#15
|
Status: Paladin
Join date: Jul 2006
Location: Sheffield, UK
Expertise: design, front-end markup
Software: Photoshop
Posts: 2,353
|
I'm sorta in the same situation as haris, assuming he is very knowledgable with php but not with in coding oop. I've been looking for a decent explanation for quite a while, finally its here!
I'll probably shoot a few questions over to you village soon
Thanks!
|
|
08-25-2007, 12:15 AM
|
#16
|
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
Posts: 6,894
|
I am extremely thrilled my tutorials are clear, I will continue adding things to it.
|
|
08-25-2007, 09:28 AM
|
#17
|
Status: Request a custom title
Join date: Dec 2005
Location:
Expertise:
Software:
Posts: 2,741
|
Originally Posted by Village Idiot
I am extremely thrilled my tutorials are clear, I will continue adding things to it.
|
I'd like you to cover how to validate posted data. Apart from that security.
|
|
08-25-2007, 01:47 PM
|
#18
|
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
Posts: 6,894
|
|
|
08-25-2007, 07:25 PM
|
#19
|
Status: Request a custom title
Join date: Dec 2005
Location:
Expertise:
Software:
Posts: 2,741
|
Originally Posted by Village Idiot
|
Why do you use cookies instead of sessions? Any particular security reason?
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|