PHP Extended Class

What is the difference between a standard clclass function and an extended class function ? Please give short examples.
Thanks,
Michael
mhoggatt1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JB04Commented:
Im guessing that was  a typo and you never meant clclass but instead meant class


The difference looks like this,



class foo {

   function test()
   {
   }

}


class bar extends foo {

}



The first is a standard class while the second extends the first class, you can get detailed info about this from the PHP manual but basically an extended class inherits all the methods and properties of the class its extending, in the above example the bar class will have the method test available to it because it inherits from foo


PHP version 4 has limited object support while PHP 5 has much more support for object, the manual also reflects this:-


PHP 4 - http://php.net/oop
PHP 5 - http://php.net/oop5



James
mhoggatt1Author Commented:
Hi James,
   Yes it was a typo. I meant to say 'a standard class function'. Could add some code to make the extended class execute some code so I can see what it would look like ?
Thanks,
Michael
JB04Commented:
Them webpages provide plenty of examples, I got the exxample below from http://php.net/manual/en/keyword.extends.php


<?php
class Named_Cart extends Cart {
   var $owner;
 
   function set_owner ($name) {
       $this->owner = $name;
   }
}
?>


You would have to have the class named Cart already defined to use the example

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mhoggatt1Author Commented:
Does the extended class basically make the function accessible from anywhere in the program ?
Thanks,
Michael
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.