|
|
|
|
Thread title: Excercises for OOP beginners? |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
09-16-2007, 12:53 AM
|
#1
|
Status: Paladin
Join date: Jul 2006
Location: Sheffield, UK
Expertise: design, front-end markup
Software: Photoshop
Posts: 2,353
|
Excercises for OOP beginners?
Ok, like a lot of people, i'm a beginner with OOP in php. I'm asking the very experienced people here, what sort of excercises or scripts to try and do first using OOP to better my knowledge?
|
|
09-16-2007, 07:55 AM
|
#2
|
Status: Member
Join date: Nov 2006
Location: In your bath.
Expertise:
Software:
Posts: 121
|
I would personally start of by making an object and writing members to change it's properties and then get used to calling those members from within the class and from outside the class.
IE
PHP Code:
class newClass { public $property; function __construct($property) { $this -> property = $property; }
public function changeProperty($property) { $this -> property = $property; }
public function nullProperty() { $this -> property = $this -> changeProperty(NULL); #In this line we called the function we made before to change the property and supplied the null value for it. } }
$Obj = new newClass("Object 1"); echo "The current property is: ".$Obj -> property."<br />"; // Outputs "The current property is: Object 1"
$Obj -> changeProperty("Object 1 V2"); echo "The current property is: ".$Obj -> property; // Outputs "The current property is: Object 1 V2"
$Obj -> nullProperty(); echo "The currenty proprety is: ".$Obj -> property; // Outputs "The current property is: "
I hope that helped. The script should work - but knowing me and my lax syntax and error checking .. it might not
|
|
09-18-2007, 01:45 AM
|
#3
|
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
Posts: 1,078
|
You should note that his code that he wrote above is for PHP5, PHP4 lacks in OOP functionality.
|
|
09-18-2007, 01:46 AM
|
#4
|
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
Posts: 6,894
|
Stay away from PHP4, it is as a whole depreciated at this point.
For scripts, make any semi-large script and implement OOP on it, try a user system.
|
|
09-18-2007, 10:55 AM
|
#5
|
Status: Paladin
Join date: Jul 2006
Location: Sheffield, UK
Expertise: design, front-end markup
Software: Photoshop
Posts: 2,353
|
Thanks for the comments, and Bursh: thanks for that, sorta helped.
|
|
09-18-2007, 04:16 PM
|
#6
|
Status: Member
Join date: Nov 2006
Location: In your bath.
Expertise:
Software:
Posts: 121
|
Originally Posted by iamAdam
Thanks for the comments, and Bursh: thanks for that, sorta helped.
|
No problem
And yes, Creative Logic is right. That script is\was for PHP 5. Some of the keywords used aren't in PHP 4.
|
|
09-23-2007, 07:15 AM
|
#7
|
Status: I'm new around here
Join date: Apr 2007
Location: Denmark
Expertise:
Software:
Posts: 17
|
Originally Posted by Village Idiot
Stay away from PHP4, it is as a whole depreciated at this point.
For scripts, make any semi-large script and implement OOP on it, try a user system.
|
For absolute beginners in OOP i would recommed them to look at the PHP4 tutorials as they give a basic and abit easier understanding of learning OOP in PHP and then move on to the differences in PHP5.
But in general i can only agree with staying away from PHP4 in general, but for learning basic OOP and testing it does the job
|
|
09-23-2007, 12:17 PM
|
#8
|
Status: Request a custom title
Join date: Dec 2005
Location:
Expertise:
Software:
Posts: 2,741
|
Originally Posted by Kalle
For absolute beginners in OOP i would recommed them to look at the PHP4 tutorials as they give a basic and abit easier understanding of learning OOP in PHP and then move on to the differences in PHP5.
But in general i can only agree with staying away from PHP4 in general, but for learning basic OOP and testing it does the job
|
I learned OOP with PHP5 and never had a problem.
Thanks to Village Idiot.
|
|
09-23-2007, 01:32 PM
|
#9
|
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
Posts: 6,894
|
Originally Posted by Kalle
For absolute beginners in OOP i would recommed them to look at the PHP4 tutorials as they give a basic and abit easier understanding of learning OOP in PHP and then move on to the differences in PHP5.
But in general i can only agree with staying away from PHP4 in general, but for learning basic OOP and testing it does the job
|
PHP4 and 5 are almost identical till you get to some advanced concepts, although some basic concepts have better functionality. Why start a beginner on bad standards?
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|