PHPextends class inheritance-PHP Tutorial-php Tutorial

Source: Internet
Author: User
The example parses the PHPextends class inheritance. PHPextends class inheritance code example :? Phpclassa {public $ x; public $ y; function _ construct ($ x0, $ y0) {$ this-x $ x; $ this-y $ y;} functiongetx () {return $ this-x;} functio

PHP extends class inheritance code example:

  1. <? Php
  2. Class {
  3. Public $ x;
  4. Public $ y;
  5. Function _ construct ($ x = 0, $ y = 0 ){
  6. $ This->X = $ x;
  7. $ This->Y = $ y;
  8. }
  9. Function getx (){
  10. Return $ this->X;
  11. }
  12. Function gety (){
  13. Return $ this->Y;
  14. }
  15. Function _ destruct (){}
  16. }
  17. Class a2 extends {}
    /* Extends is an inherited function */
  18. $ B2 = new a2 (10, 10 );
  19. Echo $ b2->Getx ()."
    ";
  20. Echo $ b2->Gety ();
  21. ?>

The above describes all the implementation steps of the PHP extends class inheritance.


Http://www.bkjia.com/PHPjc/446027.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/446027.htmlTechArticlePHP extends class inheritance code example :? Php classa {public $ x; public $ y; function _ construct ($ x = 0, $ y = 0) {$ this-x = $ x; $ this-y = $ y;} functiongetx () {return $ this-x;} functio...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.