Accessing Static Variable within Static method in a Class

Use self to access static variable or const within a class.
example:

  1. class static_class {
  2.  
  3.             private static static_variable = 'I am static ';
  4.             public static function getStaticVariable() {
  5.                  self::$static_variable;
  6.             }
  7. }

, , ,

  1. No comments yet.
(will not be published)
Submit Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Subscribe to comments feed
  1. No trackbacks yet.

SetPageWidth