class Test {
public function __construct() {
self::runTest();
Test::runTest();
}
public static function runTest() {
echo "Test running";
}
}
// echoes 2x "Test running"
new Test();
Is there any difference between self::runTest() and Test::runTest()? And if so, which one should I use?
self::runTest() when calling the method within the class and Test::runTest() when outside the class?
you should call self::runTest() from inside the class methods and Test::runTest() outside of the class methods
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With