By this symbol, we can call a class method that is static and not dependent on other initialization.
class Test {
public name;
public function __construct() {
this->name = 'Mrinmoy Ghoshal';
}
public static function doWrite(name) {
print 'Hello '.name;
}
public function write() {
print this->name;
}
}
Here the doWrite() function is not dependent on any other method or variable, and it is a static method. That's why we can call this method by this operator without initializing the object of this class.
Test::doWrite('Mrinmoy'); // Output: Hello Mrinmoy.
But if you want to call the write method in this way, it will generate an error because it is dependent on initialization.