Home >Backend Development >PHP Tutorial >PHP object-oriented static late binding static::

PHP object-oriented static late binding static::

不言
不言Original
2018-04-16 10:54:381766browse

The content of this article is about PHP object-oriented static delayed binding static::, which has a certain reference value. Now I share it with you. Friends in need can refer to it.

self represents the current class , static:: represents the last executed class (also known as static delayed binding)

Above code:

<?php

class School{
	const COUNT = 56;
	public function showInfo(){
		echo self::COUNT;
		echo &#39;<br/>&#39; . static::COUNT;          //static::代表最后执行类,self代表当前类,parent代表父类
	}
}
class University extends School{
	const COUNT = 10000;
}
$school = new University;
$school -> showInfo();

Related recommendations:

The three basic characteristics and five basic principles of object-oriented PHP

Detailed explanation of the five principles of object-oriented PHP and the single responsibility principle


The above is the detailed content of PHP object-oriented static late binding static::. 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