EllisLab text mark
Advanced Search
     
Question about helpers with same function names?
Posted: 21 July 2007 09:21 PM   [ Ignore ]
Joined: 2007-07-18
92 posts

I guess the chance of this happening is slim, but what happens if you load two helper files that contain functions with the same name. How can you choose which function you want to use? As far the documentation goes, it just mentions using a helper by calling the function name, but if you have two or more functions with the same name loaded how to pick from them? Sorry for all the questions…

 Signature 

Check it out: Critique Computer Products

 
Posted: 22 July 2007 07:10 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2007-04-22
56 posts

CI helper functions are just simple PHP functions within the global namespace.  If two helpers contain functions with the same name, PHP will error out with the a “Fatal Error: Cannor tedeclare helper_function_nanem_here()”.  Helpfully the error message will give the details of which helper declared the function originally, and which is the duplicate.  Its probably best to avoid duplicating the names of helper functions to avoid the possibility of breaking o0ur app in this way.

 
Posted: 22 July 2007 03:32 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2006-07-10
485 posts

Which would not be a problem if CI helpers were classes. Earlier, Clemens converted the CI 1.5.2 helpers to classes. The intent was to allow helpers to be extended in order to overload existing methods and to add new methods. You might find this thread useful.

http://ellislab.com/forums/viewthread/48036/