|
|
|
|
Thread title: OOP for a PHP Newbie |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
08-21-2007, 04:27 PM
|
#1
|
Status: Request a custom title
Join date: Dec 2005
Location:
Expertise:
Software:
Posts: 2,741
|
OOP for a PHP Newbie
Hello,
I'm still a PHP newbie but I'm looking forward to learn OOP concepts(according to PHP) first. The PHP manual is not detailed and very hard to grab the concepts.
Please find me a good resource for a programming beginner to learn OOP.
Salathe? WildHoney? Village Idiot?
Thanks,
Haris
|
|
08-21-2007, 04:48 PM
|
#2
|
Status: Request a custom title
Join date: Feb 2006
Location: Nottingham
Expertise:
Software:
Posts: 1,648
|
Sorry, I've never been one for reading tutorials of any kind. I read sites that spew information, such as what to use MySQL for and what not to use MySQL for, but other than that, I dive straight in and get my paws dirty.
|
|
08-21-2007, 05:22 PM
|
#3
|
Status: Narassist
Join date: May 2005
Location: USA
Expertise:
Software:
Posts: 4,469
|
In my opinion; I've yet to find a coding website that provides a straight forth answer to most coding questions without lengthy overdetailed long writings to go through. You're best bet is deconstruct a larger script and find someone you can bounce a couple of questions off of.(That someone can be google =p)
|
|
08-21-2007, 05:48 PM
|
#4
|
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
Posts: 3,820
|
My suggestion would be to initially broaden your horizons when attempting to understand OOP and what it is all about. Look back into more developed arenas such as Java. Or (and), go more theory based by looking at Object Orientation in a broader sense -- it's relation to other programming paradigms (there are lots). There is no shortage of valuable information available either digitally or in (often huge tomes) books.
If you restricted your learning specifically to PHP's OOP implementation then, in my own point of view, you wouldn't be getting the best out of your time. Nor would you get the whole picture, or anything close.
Are there any areas that you've looked into so far and had trouble understanding (please don't say, "the whole concept" )?
|
|
08-21-2007, 05:53 PM
|
#5
|
Status: Request a custom title
Join date: Dec 2005
Location:
Expertise:
Software:
Posts: 2,741
|
Originally Posted by Salathe
My suggestion would be to initially broaden your horizons when attempting to understand OOP and what it is all about. Look back into more developed arenas such as Java. Or (and), go more theory based by looking at Object Orientation in a broader sense -- it's relation to other programming paradigms (there are lots). There is no shortage of valuable information available either digitally or in (often huge tomes) books.
If you restricted your learning specifically to PHP's OOP implementation then, in my own point of view, you wouldn't be getting the best out of your time. Nor would you get the whole picture, or anything close.
Are there any areas that you've looked into so far and had trouble understanding (please don't say, "the whole concept" )?
|
Ruby on Rails. I'm jumping into PHP OOP's and will try to make my first ever OOP application. I've created one application in Ruby (Only ruby) but still didn't grabbed the WHOLE correct concept. I haven't used neither Ruby or Ruby on Rails much.
I'll try to re-create what I've created in Ruby.
Make an OrangeTree class. It should have a height method which returns its height, and a oneYearPasses method, which, when called, ages the tree one year. Each year the tree grows taller (however much you think an orange tree should grow in a year), and after some number of years (again, your call) the tree should die. For the first few years, it should not produce fruit, but after a while it should, and I guess that older trees produce more each year than younger trees... whatever you think makes most sense. And, of course, you should be able to countTheOranges (which returns the number of oranges on the tree), and pickAnOrange (which reduces the @orangeCount by one and returns a string telling you how delicious the orange was, or else it just tells you that there are no more oranges to pick this year). Make sure that any oranges you don't pick one year fall off before the next year.
|
|
|
08-22-2007, 06:35 PM
|
#6
|
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
Posts: 6,894
|
|
|
08-22-2007, 08:24 PM
|
#7
|
Status: Request a custom title
Join date: Dec 2005
Location:
Expertise:
Software:
Posts: 2,741
|
Thanks a lot Village. This would really help me in creating my first OOP script.
Thanks again.
|
|
08-23-2007, 07:48 PM
|
#8
|
Status: I'm new around here
Join date: Aug 2007
Location:
Expertise:
Software:
Posts: 4
|
*Bookmarked, saved, etc*
This was really, really helpful. I've been looking for an explanation like this for quite a while now. Thanks dude.
|
|
08-24-2007, 09:20 PM
|
#9
|
Status: Request a custom title
Join date: Dec 2005
Location:
Expertise:
Software:
Posts: 2,741
|
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.
|
|
08-24-2007, 09:35 PM
|
#10
|
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
Posts: 6,894
|
-deleted response to deleted post-
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|