I have found that writing PHP code within classes can become rather long:
$this->parser->parse_syntax($this->get_language_path($this->language),
$this->elements,
$this->regex);
For example, in Java a class instance can call its methods by name without referencing this, is there a way to achieve shorter code in PHP without using this and self every time you have to read a value?
No, in PHP if you want to run object’s method or read/write property from inside of object you must write
$thisto refer that object instance.PS. You can do at the beginning of each method something like this:
$s = $thisand use$sthen, but it’s strongly unrecommended, you shouldn’t do that and it will be best, if you forget that you read this paragraph 🙂