Non-static method Pages::view() cannot be called statically |
Hello,
I'm developing a site and used the example provided in the documentation here: http://www.codeigniter.com/user_guide/tu...pages.html to be able to have one controller for all my static pages. It works fine on my localhost but when I push online this is what happens: Code: Severity: Runtime Notice After searching online some people say adding 'static' to PHP Code: public static function view($page = 'home'){ Any ideas? Thank you (08-31-2016, 11:43 PM)orionstar Wrote: You can't use static for action functions! Static is a php keyword it's not related with static pages... Without the static keyword that's my error message above "Non-static method Pages::view() cannot be called statically"
This is what my code looks like
PHP Code: class Pages extends CI_Controller {
You need a __construct() method in your controller, if you are extending another class you always use a constructor to access the constructor of the other class.
Also make sure that you add the routes. If that does not fix it then you have other problems. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(09-01-2016, 11:40 AM)InsiteFX Wrote: You need a __construct() method in your controller, if you are extending another class you always use a constructor to access the constructor of the other class. The constructor function can be omitted, then the parent's constructor will be executed. @keld I think we need more info to help you: Which PHP version do you use? (you can use phpinfo() to find it out...) Which CodeIgniter version do you use? (you can find the version here: system/core/CodeIgniter.php line 58) Please show us your routes from the routes.php!
Sorry for all the trouble I updated my server to the latest version of PHP (5.6.24) available on my shared host and all the errors magically disappeared. I realized with horror that I was on PHP 5.2 (kill me).
|
Welcome Guest, Not a member yet? Register Sign In |