|
PHP: create a static method<?php
class StaticMethodTest {
public static function doSomething() {
echo 'Doing something...' . PHP_EOL;
// Note: you cannot use "$this" from inside a static function, it will cause a fatal error
}
}
// A static method can be called without an instance of the class using the double colon '::' operator:
StaticMethodTest::doSomething();
|