CodeIgniter Forums
Fatal error because of using the same key? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Fatal error because of using the same key? (/showthread.php?tid=81376)



Fatal error because of using the same key? - sprhld - 02-21-2022

Hello!

Maybe someone can explain me this error, which I solved but I don't understand what happens here.


Quote:Fatal error: Cannot redeclare App\Models\creator() (previously declared in /var/www/app/Models/PathModel.php:38) in /var/www/app/Models/PathModel.php on line 38


This happens, when it comes to the second line below. "creator()" is only used in "createNaviagatorArray()" in the first line (its a function in this function). "getChildrenWithType()" is empty!

PHP Code:
$this->data['sidebar'] = $this->subjects->fillNavigatorArray($this->paths->createNavigatorArray($this->id));
$this->data['sidebar'] = $this->subjects->getChildrenWithType(); 

It works with

PHP Code:
$this->data['foo'] = $this->subjects->getChildrenWithType(); 
Why? I only accidentally used the same key...

Huh