create a new object CI4 |
Goodmorning everyone,
i am using codeigniter version 4 rc3. I would like to create a model object for CI3 compatibility. PHP Code: <?php namespace App\Controllers; usage PHP Code: public function index() It gives me error in creating the object. Thank you
Hi, in PHP the actual name for an empty class are this.
PHP Code: $this->model = new stdClass(); Don't forget to add this in your BaseConroller. And initialize it there, so that you can use it all controllers. PHP Code: protected $model; (02-09-2020, 03:05 AM)jreklund Wrote: Hi, in PHP the actual name for an empty class are this. The problem is in php 7.4 PHP Code: new stdClass(); the error is: Class 'App\Controllers\stdObject' not found I read that for php write: (object) Null; or new stdClass (); it's the same thing. But I don't understand why he can't find the class. i don't know if i have to add use something \\ other \\ object functions Thanks
Try one of these and see if it will work for you.
PHP Code: $this->model = new \stdClass(); What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |