I am new to CodeIgniter and wonder. I am a little confused about classes, libraries and objects.
Does CodeIgniter replace the regular PHP method of user objects, i.e. $var = new car();, with libraries, that is $this->load->library('some_library'); $this->some_library->some_function();?
$var = new car();
$this->load->library('some_library'); $this->some_library->some_function();
If both are valid, is there a difference? If so, what are the differences and when do I use one over the other? What is more common / correct?
I ask because I created the class, but I'm not sure if this is the correct way to create it.
Thanks in advance
CI , , // .
( ) -singleton- require . , , , .
require
($this->load) , , (, - , , . ) $this.
$this->load
. , "" , .
, , . "", CI- .
CodeIgnitier. PHP. , , ...
, "" - library, , ( , ). 1 ( ).
library
factory. , , .
, . ..
, Inversion of Control (, , CodeIgniter).
car, new car(). , $var a racecar? $var , car, . , , car - , . , , . , $var mockcar. , $var = new car().
car
new car()
$var
racecar
mockcar
$var = new car()
?
Source: https://habr.com/ru/post/1764344/More articles:PHP structure for building CMS, session and REST - phpHow to get all possible combinations of neighboring elements in the following order using Perl? - perlA call to android.speech.RecognizerIntent API leads to the Connection Error dialog, shows a warning "call_package" in the log - androidrand () sowing with time problem () - cWhich database to use? - javaDjango / python converts my message data from JavaScript - jsonDetect deferred support script without testing - javascriptunit tests DAO - unit-testingCapturing icons with node.js - node.jsA service configured in spring / resources.groovy does not have a Hibernate session - grailsAll Articles