Several questions concerning CI4 controller |
(03-24-2020, 09:03 AM)bitshifter Wrote: 1.) I want to put the $data array outside the whole class or outside the functions (both possible in C/C++) and pass them as a parameter to the function so there is less code. How can I accomplish that in Codeigniter/php? There is more than one way to clean up the $data code. One easy way is to create a class property. PHP Code: class Contact extends Controller To use the property instead of this code PHP Code: echo view('contact/contact', $data); You use the $this object reference which can be thought of as being roughly equivalent to the c++ "this" pointer. PHP Code: echo view('contact/contact', $this->data); |
Messages In This Thread |
Several questions concerning CI4 controller - by bitshifter - 03-24-2020, 09:03 AM
RE: Several questions concerning CI4 controller - by dave friend - 03-24-2020, 06:03 PM
RE: Several questions concerning CI4 controller - by bitshifter - 03-25-2020, 08:22 AM
RE: Several questions concerning CI4 controller - by dave friend - 03-25-2020, 09:52 AM
RE: Several questions concerning CI4 controller - by bitshifter - 03-25-2020, 12:00 PM
RE: Several questions concerning CI4 controller - by dave friend - 03-25-2020, 12:14 PM
RE: Several questions concerning CI4 controller - by bitshifter - 03-28-2020, 12:13 PM
RE: Several questions concerning CI4 controller - by dave friend - 03-28-2020, 02:33 PM
RE: Several questions concerning CI4 controller - by bitshifter - 04-01-2020, 01:06 PM
RE: Several questions concerning CI4 controller - by maxxd - 04-02-2020, 03:31 PM
RE: Several questions concerning CI4 controller - by bitshifter - 04-17-2020, 07:09 PM
|