菜单

Method of using static member method and static member attribute of PHP

2017年11月22日 - PHPer

Method of using static member method and static member attribute of PHP

Static member methods and static member properties

Following use:

Class Wan

{

Public static $time =’1 days’;

Public static function XXX ()

{

Echo ‘this is a static member method’;

/ / to use the self keyword in the class name or member property inside the class call the static, recommend the use of self inside the class

Echo self:: $time;

Echo wan:: $time;

When members of the class / internal call static, also want to use the self class name or keywords, recommend the use of self inside the class

Wan:: yukuai ();

Self:: yukuai ()

}

Public static function yukuai ()

{

Echo ‘cheer up’;

}

}

Be careful

The static member attribute belongs to the public, and does not belong to a specific object

发表评论

电子邮件地址不会被公开。