I'm learning to develop web applications but also love to learn how to build quality OpenCart extensions. I actually have one quick question. I just figured OpenCart does not allow properties directly inside classes, as opposed to how I learned Object Oriented Programming using PHP. The question is... Why not? Am I allowed to declare properties inside methods instead? Or how exactly does this work?
Using version 3.0.3.7 on localhost
Use command lines to search the lines for:EMGX wrote: ↑Mon Aug 02, 2021 5:46 amHi everybody,
I'm learning to develop web applications but also love to learn how to build quality OpenCart extensions. I actually have one quick question. I just figured OpenCart does not allow properties directly inside classes, as opposed to how I learned Object Oriented Programming using PHP. The question is... Why not? Am I allowed to declare properties inside methods instead? Or how exactly does this work?
Using version 3.0.3.7 on localhost
Code: Select all
$this->load->controller
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
If I were to declare a property:
Code: Select all
class ControllerClassName extends Controller {
$property;
public function methodName {
$property = 1;
}
}
Guess you mean more such like that:EMGX wrote: ↑Mon Aug 02, 2021 4:41 pmIf I were to declare a property:
The actual page I'm loading will give me an "Unexpected variable" message, making it impossible the way I'm doing it here. This is allowed using the 'generic' PHP you're talking about, but apparently OpenCart handles this differently.Code: Select all
class ControllerClassName extends Controller { $property; public function methodName { $property = 1; } }
Code: Select all
class ControllerClassName extends Controller {
private $property; // or public/static
public function methodName(): int {
$this->property = 1;
}
}
Hmm .... as opposed to how I learned Object Oriented Programming using PHP ..
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
You're using it improperly, that's all. Please, continue to study the coding.EMGX wrote: ↑Mon Aug 02, 2021 4:41 pmCode: Select all
class ControllerClassName extends Controller { $property; public function methodName { $property = 1; } }
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
That's what I already wrote above ..thekrotek wrote: ↑Mon Aug 02, 2021 5:18 pmYou're using it improperly, that's all. Please, continue to study the coding.EMGX wrote: ↑Mon Aug 02, 2021 4:41 pmCode: Select all
class ControllerClassName extends Controller { $property; public function methodName { $property = 1; } }
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
Users browsing this forum: adycobra2003, Bing [Bot], Google [Bot], OSWorX, paulfeakins and 417 guests