I am making a start in CodeIgniter, I am trying to understand the MVC pattern, which is getting a bit complicated Because I'm moving forward with CodeIgniter, this is my controller Looks like hello.php:
& lt ;? Php square extends Hello CI_Controller {var $ name; Var $ color; Function Hello () {Origin: Controller (); $ This- & gt; Name = 'laryai'; $ This- & gt; Color = 'red'; } Show show () {$ data ['name'] = $ this- & gt; Name; $ Data ['color'] = $ this- & gt; Colour; $ This- & gt; Load-> View ('show_message', $ data); }}? & Gt; view ie show_message.php
& lt; P align = "center" & gt; Hello & lt; Font color = "& lt;? = $ Color? & Gt; & Lt ;? = $ Name & gt; & Lt; / Font & gt; .. !!!! & Lt; / P & gt; When I run this script, this error returns
Fatal error: call the undefined method CI_Controller :: Controller () in C: \ xampp \ Htdocs \ CodeIgniter \ application \ controllers \ hello.php on line 8 PS I am using CodeIgniter version 2.0 so that I change the class name to CI_Controller < / Div>
function hello () {parent: controller (); $ This- & gt; Name = 'laryai'; $ This- & gt; Color = 'red'; } Change your constructor code with this
function __construct () {origin: __ creation (); $ This- & gt; Name = 'laryai'; $ This- & gt; Color = 'red'; }
Comments
Post a Comment