Non-static method Pages::view() cannot be called statically - 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: Non-static method Pages::view() cannot be called statically (/showthread.php?tid=66067) |
Non-static method Pages::view() cannot be called statically - keld - 08-31-2016 Hello, I'm developing a site and used the example provided in the documentation here: http://www.codeigniter.com/user_guide/tutorial/static_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 RE: Non-static method Pages::view() cannot be called statically - orionstar - 08-31-2016 You can't use static for action functions! Static is a php keyword it's not related with static pages... Without the "static" word, exactly what is the error message? RE: Non-static method Pages::view() cannot be called statically - keld - 09-01-2016 (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" RE: Non-static method Pages::view() cannot be called statically - keld - 09-01-2016 This is what my code looks like PHP Code: class Pages extends CI_Controller { RE: Non-static method Pages::view() cannot be called statically - InsiteFX - 09-01-2016 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. RE: Non-static method Pages::view() cannot be called statically - orionstar - 09-01-2016 (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! RE: Non-static method Pages::view() cannot be called statically - keld - 09-01-2016 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). |