parent::__construct();
$this->displayName = $this->l('Responsive products featured');
$this->description = $this->l('Displays featured products and categories in your homepage.');
$this->
include_once($this->local_path.'/classes/ResponsiveHomeFeaturedClass.php');
You will see that it is difficult to understand why the last statement uses two $this ?
(I'm not sure if you have an error in your pasted code, since include_once
is a commonly used built-in function, but I suppose it could also be an instance function on an object...)
There's no reason why any one line of code can't reference $this
twice, or as many times as it needs to. $this
is just a reference to an object. So in this line of code:
$this->include_once($this->local_path.'/classes/ResponsiveHomeFeaturedClass.php');
It's just calling the include_once
function and passing it a value, which includes the local_path
value. This would accomplish the same thing:
$some_local_path = $this->local_path;
$this->include_once($some_local_path.'/classes/ResponsiveHomeFeaturedClass.php');
But it would be using an unnecessary temporary variable. include_once
is just a function, and local_path
is just a value. The latter can be used as a parameter for the former.
You cannot have include_once
as your method because it is reserved keyword!
The following code
class Test {
function include_once() {
}
}
will NOT work:
Parse error: syntax error, unexpected T_INCLUDE_ONCE, expecting T_STRING
It is a very good thing to keep you away from troubles.
The code in question would work if include_once
would indeed be a method (which it can't be), it is, however, not a good practice to insert an empty line.
Concerning $this
- it is part of your method or property call, so in general it can be used as many times as you need to refer to your methods or properties (from the same class instance).