CodeIgniter Forums
load is unknown? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: load is unknown? (/showthread.php?tid=54637)



load is unknown? - El Forum - 09-18-2012

[eluser]Firenter[/eluser]
Hi there forums!
I just set up a new site, and I wanted to start from scratch (with CI of course).
I've copied the welcome controller into my own Index controller and created a homepage that should just say 'Welcome!'.
But whenever I try to load the page it gives me this:
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Index::$load

Filename: controllers/index.php

Line Number: 7

It seems it's not properly accessing the load view function, the code looks like this:
Code:
$this->load->view('home');

I don't see what I did wrong here, it should just be something simple right?


load is unknown? - El Forum - 09-18-2012

[eluser]Aken[/eluser]
Paste your entire controller's code. I'm guessing you misspelled something.


load is unknown? - El Forum - 09-18-2012

[eluser]wiredesignz[/eluser]
Do not use reserved words for Controller naming.

Refer: http://ellislab.com/codeigniter/user-guide/general/reserved_names.html


load is unknown? - El Forum - 09-19-2012

[eluser]brownmarsh12[/eluser]
Solving for Facebook's "load-error: unknown" error Spent about the last 20 minutes debugging a mysterious error


load is unknown? - El Forum - 09-19-2012

[eluser]Firenter[/eluser]
Right so the problem was that I forgot the constructor at the beginning of the controller. Simple as that, without the constructor it probably won't know what to do Tongue

Also @wiredesignz you can use index as a controller name, I've done it before and never ran into trouble...


load is unknown? - El Forum - 09-19-2012

[eluser]wiredesignz[/eluser]
@Firenter, A class constructor is not normally required unless you are carrying out some initiation for the class. PHP5 will automatically run the parent constructor in it's absence.

The reason that your application failed and required an empty __constructor is because the index method is considered to be the constructor if your controller class name is also Index.(prior to PHP5.4)

So the parent constructor was never being called and the Loader was never initialized.

This is why the User Guide makes note of reserved words, to avoid this kind of confusion.
(And possibly with some carry over from PHP4 in some cases)



load is unknown? - El Forum - 09-19-2012

[eluser]Firenter[/eluser]
Thanks for the explanation, learning new things everyday!