![]() |
Problem with custom helper, any clues would be much appreciated - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Problem with custom helper, any clues would be much appreciated (/showthread.php?tid=16801) |
Problem with custom helper, any clues would be much appreciated - El Forum - 03-16-2009 [eluser]Unknown[/eluser] Hi all: I am new to CI and php. I am working on a project that needs a set of common functions to format data. I did the prototype with the functions in the controller. I them moved them to a file "lbfile_helpers.php": <?php function timestamp() { return date(”Y-m-d H:i ![]() } ?> when I try to call this from a form via submit and a route I get: Fatal error: Call to undefined method Lblanding::timestamp() in /Users/richard/Sites/CI/system/application/controllers/lblanding.php on line 163 If the function is declared in the class, everything works. I am sure this is a simple error, but I have tried everything I can think of. Thanks Richard Problem with custom helper, any clues would be much appreciated - El Forum - 03-17-2009 [eluser]davidbehler[/eluser] Pretty sure you are trying to call the function like this: Code: echo $this->timestamp(); Code: echo timestamp(); As you moved the function from your controller to the helper it no longer is a method of said controller but a simple function. Problem with custom helper, any clues would be much appreciated - El Forum - 03-17-2009 [eluser]Unknown[/eluser] Thanks much. It is amazing how you can read the same instructions several times at 1:00 AM and get them wrong every time. Richard |