Reputation: 23
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();
Upvotes: 1
Views: 17
Reputation: 2691
Use self::
to access static properties:
public static function getProperties() {
return [self::$test1, self::$test2];
}
Upvotes: 1