class Example { public static $foo = "Hello"; public static function show() { echo self::$foo; } } Example::show(); // Output: Hello
class Example { private $bar = "World"; public function greeting() { echo "Hello " . self::$bar; } } $obj = new Example(); $obj->greeting(); // Output: Hello WorldIn this example, we define a class Example with a non-static property $bar and a non-static method greeting(). The greeting() method uses self keyword to refer to the non-static property $bar of the current object. Package library: The PHP self keyword is a built-in feature of PHP, so it does not belong to any package library.