When I started learning OOP programming, I read that everything is an object, the most time to develop in PHP Here is an important role of arrays for example:
class product {private $ data = array}; For example: For example:
public function __ composition () {$ this- & gt; Data ['settings_1'] = 'a'; $ This- & gt; Data ['setting_2'] = 'b'; $ This- & gt; Data ['setting_3'] = 'c'; $ This- & gt; Data ['setting_4'] = 'D'; $ This- & gt; Data ['setting_5'] = 'E'; }}
Do you mean making the classes for everything while using PHP? For example:
Classroom Product {Private $ settingEND_A_1, $ setting_2, $ settings_3, $ settings_4, $ setting; } And then in another category (example model), return the item to the class product immediately and instead of the array (such as for controller)?
"Everything is an object" in mindset, keep in mind that it applies to languages that OO was based from 1 day PHP is not one of those languages, things were added after the fact, your simple variable type objects in PHP are small, they are & amp; Simple pieces of memory.
This division is hair, but if you do not need to use any object in PHP, then not simple arrays are lighter than the array. By lightening I mean that they use less rams, and in turn, move a bit faster.
The best advice you have about writing PHP is KISS (keep this simple stupid).
No comments:
Post a Comment