PHP Object-oriented explanation

Source: Internet
Author: User

Object-oriented examples

Understanding: Reducing the redefinition of variables such as variables before the Var $ idea more clearly

Class Yuan----do not add () to create class {var$banjing;//a member variable of a circle class this variable is preceded by the Var $ z variable when the object's        //area, member method    functionMianji () {return3.14*$ This->banjing*$ This-banjing; }}  Thisrefers to an object (instance) that references this class $maxyuan=NewYuan (); $maxyuan->banjing = 10;//You don't need to add any symbolic symbols to the banjing before you can have a definition in a class.//build a small circle$minyuan =NewYuan (); $minyuan->banjing = 5; Echo $maxyuan->mianji ()-$minyuan->mianji ();
Finding the area difference of two circles (object-oriented method)

Process-oriented is a process-oriented problem.

// find the area of the shadow between two circles /* $r 1 = ten; $r 2 = 5; $mj = 3.14* $r 1* $r 1-3.14* $r 2;echo $r; */
process-oriented area

The difference between a class and an object

Category 1: Abstract many objects of ambiguity

2. Object: an instance of an instance class

When using object-oriented, you must first initialize (instantiate)---> Tell the computer that it belongs to a certain class of

In the title: $maxyuan = new Yuan (); Separate a frame from the Circle class (instance independent individual (object)) Add content below (see above)

PHP Object-oriented explanation

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.