Want Help - 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: Want Help (/showthread.php?tid=27310) |
Want Help - El Forum - 02-07-2010 [eluser]Bhushan[/eluser] Hi all, i m new to codeigniter.i have created function in helper and want to access it from controller but it shows 'Call to undefined method' how can i do this? helper file is stored in application/helper. i have loaded helper file using $this->load->helper('MY_array_helper'); then i used function as $data['result']=$this->getdata(); Want Help - El Forum - 02-07-2010 [eluser]umefarooq[/eluser] can you tell me the helper file name your helper file name should be helpername_helper.php and then call it form controller Code: $this->load->helper('helpername'); Want Help - El Forum - 02-07-2010 [eluser]Bhushan[/eluser] helper file is 'MY_array_helper.php' and function name is getdata(). Want Help - El Forum - 02-07-2010 [eluser]pistolPete[/eluser] Did you save your helper extension in application/helpers/? How do you load the helper? Want Help - El Forum - 02-08-2010 [eluser]aidehua[/eluser] Try loading the helper like this: Code: $this->load->helper('array'); Helper file names end in "_helper.php", but to load them in a CI controller, you don't use the "_helper.php" part of the file name. Want Help - El Forum - 02-08-2010 [eluser]danmontgomery[/eluser] Quote:then i used function as $data[‘result’]=$this->getdata(); Helpers aren't class members. Use: Code: $data['result'] = getdata(); |