This article describes the static static properties and static methods of php. Share it for your reference. The details are as follows:
<?php /* * static */ /*Static: belongs to a class and not to a single object (global, shared by all objects) * Static properties: When calling static properties within a class's method, do not use the $this-> method, but use the self:: method. * Static method: * Can be called when the class does not have any object. *It's okay to use it as an ordinary method *The normal method cannot be called in static methods * * */ class xin { static private $name; public function setname($namec) { self::$name = $namec; } public function getname() { return self::$name; } static public function name($namecc) { echo "I am $namecc"; } } $xind = new xin(); $xind->setname("Site <br/>"); echo $xind->getname(); $oldd = new xin(); $oldd->setname("Government <br/>"); echo $oldd->getname(); echo $xind->getname(); echo xin::name("Star"); echo "<br/>"; ?>
The operation results are as follows:
place
government
government
I am Stars
I hope this article will be helpful to everyone's PHP programming.