PHP object-oriented static late binding static::

不言
Release: 2023-03-23 22:20:01
Original
1675 people have browsed it

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();
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!