Results 1 to 10 of 12
-
15th Oct 2010, 03:52 PM #1OPMemberWebsite's:
Doxsters.netWhat is the point of the php extends in relation to classes?
I just don't get it. Why create one class, eg
PHP Code:class user{
function login(){
//login stuff
}
}
PHP Code:class admin extends user{
function admin(){
//admin stuff
}
}
timtamboy63 Reviewed by timtamboy63 on . What is the point of the php extends in relation to classes? I just don't get it. Why create one class, eg class user{ function login(){ //login stuff } } then use the extends keyword like so Rating: 5
Need a Designer/Web Developer? Click Me
MSN: PM me for it.
Email(Preferred):timtamboy63@gmail.com
"Power Corrupts. Absolute Power Corrupts Absolutely"
-
15th Oct 2010, 03:55 PM #2Member
I'll answer your question with another question: "What if you have 1 milion types of users. Would you copy paste the same functions over and over again on all files?!"
This is one of the basics of OOP.
Quick reference for intelectual answer:
http://en.wikipedia.org/wiki/Inherit...d_programming)
-
15th Oct 2010, 04:00 PM #3OPMemberWebsite's:
Doxsters.netOoh, I see, thanks, I guess I wasn't thinking of it in terms of larger applications.
Need a Designer/Web Developer? Click Me
MSN: PM me for it.
Email(Preferred):timtamboy63@gmail.com
"Power Corrupts. Absolute Power Corrupts Absolutely"
-
15th Oct 2010, 06:11 PM #4MemberWebsite's:
litewarez.net litewarez.com triniwarez.comAn Example:
PHP Code:class Curl
{
var $url,$postparams;
protected $curl;
private function __construct()
{
$this->curl = curl_init();
}
public function submit()
{
//Code to submit
}
public function request()
{
//Code to request
}
}
PHP Code:class SubmitPost extends Curl
{
public function __construct($url,$data)
{
$this->url = $url;
$this->postparams = $data;
}
public function go()
{
return $this->submit();
}
}
PHP Code:class RequestPage extends Curl
{
public function __construct($url)
{
$this->url = $url;
}
public function go()
{
return $this->request();
}
}
Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
-
16th Oct 2010, 06:48 AM #5OPMemberWebsite's:
Doxsters.netI see, thanks
Need a Designer/Web Developer? Click Me
MSN: PM me for it.
Email(Preferred):timtamboy63@gmail.com
"Power Corrupts. Absolute Power Corrupts Absolutely"
-
16th Oct 2010, 06:52 AM #6Respected DeveloperWebsite's:
X4B.org
-
16th Oct 2010, 07:14 AM #7You can call me G
Speaking from the OOP perspective, inheritance is a very essential feature. Let me generalize this.
Say you have a class called flowers. Now you create another class called Rose. now the Rose class has ALL the properties of flowers so it "inherits" it from the parent aka the flowers class and the rose class is unique in itself.. Hope that makes it clear.. this was the way I was taught in grade 10 while learning Java
My Langotiya Yaars (Chaddi buddies): JmZ, humour, Chutad, Esotorisk, l0calhost, Daniel, Mind Freak?, TLK, Amz
-
16th Oct 2010, 07:18 AM #8Member
-
16th Oct 2010, 07:42 AM #9OPMemberWebsite's:
Doxsters.netahh, yeah that does make it pretty clear. Also, do i use the parent keyword to access functions from the parent class?
Need a Designer/Web Developer? Click Me
MSN: PM me for it.
Email(Preferred):timtamboy63@gmail.com
"Power Corrupts. Absolute Power Corrupts Absolutely"
-
16th Oct 2010, 07:45 AM #10MemberWebsite's:
Installtheworld.blogspot.com Redswitches.comgunda316 you were taught JAVA in grade 10
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Microsoft extends Windows 7 support to 2020
By ShareShiz in forum News & Current EventsReplies: 10Last Post: 24th Feb 2012, 03:18 PM -
What's the point of...
By tres in forum General DiscussionReplies: 3Last Post: 30th Oct 2010, 01:02 AM -
C# Basics I - Classes in C#
By iFlames in forum Web Development AreaReplies: 9Last Post: 29th Jun 2010, 05:33 PM -
LE with live-point.net
By SpiderZq in forum Traffic Market (Buy, Sell and Trade)Replies: 3Last Post: 2nd Sep 2009, 09:08 PM -
PHP Tutorial (Creating Classes)
By litewarez in forum Tutorials and GuidesReplies: 0Last Post: 14th May 2009, 11:40 AM
themaCreator - create posts from...
Version 3.24 released. Open older version (or...