Home  >  Article  >  Backend Development  >  Is there any object in php

Is there any object in php

Guanhui
GuanhuiOriginal
2020-05-08 14:27:572888browse

Is there any object in php

Is there an object in php?

There is an object in php. Its usage is: first, you can write an object through the class keyword class, or you can inherit a class through the extends keyword; then write methods and attributes in the class; and finally instantiate the object by using new followed by the class name.

Sample code:

class ClassName extends AnotherClass
{
    //属性
    public $name = 'xiaoming';
    
    //构造方法
    public function __construct()
    {
        
    }
}

//实例化类
$obj = new ClassName();

Recommended tutorial: "PHP Tutorial"

The above is the detailed content of Is there any object in php. 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