I just wanna get return class properties in not instantiated class use. There is no way to instance this class? Please tell me…! My example is below↓↓
<?php class MyTest { public static $test1 = 'a'; public static $test2 = 'b'; public static function getProperties() { //how to code here...? } } //plz return $test1, $test2 MyTest::getProperties();
Advertisement
Answer
Use self::
to access static properties:
public static function getProperties() { return [self::$test1, self::$test2]; }