Home >Backend Development >PHP Tutorial >Looking back suddenly - object-oriented

Looking back suddenly - object-oriented

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-29 08:59:13935browse

After learning C and Java, I waited until I learned PHP. Today I finally understood what object-oriented is.
For example: a mobile phone is a class, the keyboard, battery, screen, etc. are member variables, and making phone calls, sending text messages, etc. are methods.
Object instantiation is like giving us all the functions of mobile phone A, converting the class into an object, and we (the object) can call any part of the mobile phone.
code:
class MyPc{
var $key;
public $name;
function vod(){
echo "php my favorite";
}
}
$pc1=new MyPc();//instantiation
$pc1->key="php";//Output php letters
echo $pc1->vod();//Output php my favorite

The above has introduced the suddenly looking back - object-oriented, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn