Home >Backend Development >PHP Tutorial >The concept of PHP classes and objects

The concept of PHP classes and objects

小云云
小云云Original
2018-03-31 13:10:591248browse

This article mainly shares with you the concepts of PHP classes and objects, mainly in the form of code. I hope it can help you.

The concept of PHP classes and objects

Object-oriented –>About array programming

class People {
    public $name = 'nobody';    public function cry() {
        echo '呱呱坠地';
    }
}$a = new People();

print_r($a);echo $a->name,&#39;<br />&#39;,$a->height,&#39;<br />&#39;;$b = array(&#39;name&#39;=>&#39;nobodyB&#39;,&#39;height&#39;=>&#39;40B&#39;);echo $b[&#39;name&#39;],&#39;<br >&#39;,$b[&#39;height&#39;];echo &#39;<br >&#39;;// ===对象调用其方法(函数)=== //$a->cry();

Related recommendations:

Classes and Detailed explanation of object inheritance

Detailed explanation of classes and objects (inheritance) in php_php examples

Detailed explanation of classes and objects in php

The above is the detailed content of The concept of PHP classes and objects. For more information, please follow other related articles on the PHP Chinese website!

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