I’m just asking based on experience with other languages that can disambiguate method calls from global function calls based on class scope – eg:
class Foo {
function bar(){
echo 'bletch';
}
function baz(){
$this->bar();
}
}
So I guess I’m asking whether there’s another way of doing $this->bar(), or in other words, how can I leave out $this, which just seems redundant given the context?
No, you can’t access
bar()from withinbaz()without$this->in PHP as you can easily have global functionbar()that is not part of any class/object (which is the difference then most of those languages you are reffering to), which would result in collision.