Example parsing PHP extends class inheritance _php tutorial

Source: Internet
Author: User
Tags gety

PHP extends class inheritance code example:

  1. < ? PHP
  2. Class a{
  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 a{}
    /*extends is an inheritance function */
  18. $ B2 = New A2 (10,10);
  19. echo $b 2- > getx (). " <br> ";
  20. echo $b 2- > gety ();
  21. ?>

The above-described content is the PHP extends class inherits all the implementation steps.


http://www.bkjia.com/PHPjc/446027.html www.bkjia.com true http://www.bkjia.com/PHPjc/446027.html techarticle PHP 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.