Object Oriented PHP learning notes (top)

Source: Internet
Author: User
Tags object oriented php

Object-oriented:

<?PHP//class//object//class is an abstraction of an object; An object is an instantiation of a classclassren{//member Variables    var $top; var $zhong; var $sex; var $name; //member properties are not in PHP;//Member Methods    functionEat () {Echo"Eat with your hands."; }    functionRun () {Echo"Run fast."; }}//Class Instantiation Object$r=NewRen ();$r->name = "Zhang Da";Echo $r->name

For example, to the circle area

For simple calculations, it may be a bit more complex for object-oriented, but it is more convenient for more complex and frequently changed data code.

//Object-oriented//storage radius variable classyuan{//defines the radius of a circle    var $banjing; //method of Calculating Circle area    functionMianji () {return3.14*$this->banjing*$this-banjing; }        }//Find Area$r 1=NewYuan;$r 1->banjing=10;$DMJ=$r 1-Mianji ();$r 2=NewYuan;$r 2->banjing=5;$XMJ=$r 2-Mianji ();Echo $DMJ-$XMJ;?>

Object Oriented PHP learning notes (top)

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.