[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

PHP Extended Class

Posted on 2006-04-19
6
Medium Priority
?
369 Views
Last Modified: 2008-03-17
What is the difference between a standard clclass function and an extended class function ? Please give short examples.
Thanks,
Michael
0
Comment
Question by:mhoggatt1
  • 2
  • 2
4 Comments
 
LVL 7

Expert Comment

by:JB04
ID: 16491135
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
0
 

Author Comment

by:mhoggatt1
ID: 16492365
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
0
 
LVL 7

Accepted Solution

by:
JB04 earned 1000 total points
ID: 16492399
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
0
 

Author Comment

by:mhoggatt1
ID: 16510275
Does the extended class basically make the function accessible from anywhere in the program ?
Thanks,
Michael
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month20 days, 13 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question