php Use of Static Member Methods and Static Member Properties

  • 2021-08-12 02:14:57
  • OfStack

php Use of Static Member Methods and Static Member Properties

Static member methods and static member properties

Use as follows:


class wan
 {
  public static $time = '1 Days ';
   public static function xxx()
   {
    echo ' This is what it is 1 Static member methods ';
   // When calling static member properties inside a class, use the self Or class name keywords, which are recommended to be used inside the class self
     echo self::$time;  
     echo wan::$time;

   // When calling static member methods inside a class, you should also use self Or the class name keyword, which is recommended to be used inside the class self
     wan::yukuai();
     self::yukuai()
   }

   public static function yukuai()
   {
    echo ' Cheer up ';
   }
 }

Attention

Static member attributes are public and do not belong to a specific object.

If you have any questions, please leave a message or go to this site community to exchange and discuss, thank you for reading, hope to help everyone, thank you for your support to this site!


Related articles: