PHP Object-oriented

Source: Internet
Author: User

Object oriented

1. Class
Abstracted by a multitude of objects.

2. Objects
All objects together
instantiated by the class.

Find the area of the shadow between two circles
$SR 1=10;
$SR 2=5;
$MJ =3.14* $sr 1* $sr 1-3.14* $sr $SR 2;
Echo $MJ;
Process-oriented approach

1. Abstract a circle into a class;
Class Yuan
{
var $banjing;//A member variable of a circle class
Area, member method
function Mianji ()
{
return 3.14* $this->banjing* $this->banjing;
}
}


Instantiating an Object
$yuan = new Yuan ();//new an object from an abstract model that is created as an instance
$yuan->banjing=10;//using Object tuning members
echo $yuan->mianji ();//Call method
Var_dump ($yuan);

$this keyword represents the object inside a class
Making a great circle
$maxyuan =new yuan ();
$maxyuan->banjing=10;
Making small Circles
$minyuan =new yuan ();
$minyuan->banjing=5;
echo= $maxyuan->mianji ()-$minyuan->banjing ();


PHP Object-oriented

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.