Welcome Guest, Not a member yet? Register   Sign In
Class App\Controllers\stdClass not found error
#1

I have a controller with the following code, working fine till CI 4.5 version.
Code:
34     public function index(): string
35     {
36        $model = new RegisterModel();
37        $total = new stdClass;
38        $total->registrations = $model->countRegistrations();
39        $total->pictures = $model->countPictures();
40        $this->viewData['total'] = $total;
41        return view('pages/public/registers/civil/main', $this->viewData);
42    }
After the latest update I get the error: Class "App\Controllers\stdClass" not found
What's wrong with the code above? Thanks a lot for any hint
Reply
#2

Fixed: it seems to be fixed using:

$total = new \stdClass();
Reply
#3

(This post was last modified: 03-30-2025, 05:33 AM by InsiteFX.)

Because that is the correct way of initializing it.

PHP.net
PHP Code:
$obj = new stdClass(); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB