Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter doesn't like methods in views?

I'm playing around with CodeIgniter; hoping to convert some of my old, ugly PHP into a more maintainable framework. However, I've come across a rather frustrating roadblock - I can't seem to define methods in my views. Any time I try I get a completely blank page, and when I look in the debug log the processing seemed to stop after the view was loaded. Can I define methods within views? If not, why, and what workarounds would you suggest?

Note: The method has to do with formatting output strings.

like image 848
Kyle Cronin Avatar asked Apr 09 '26 05:04

Kyle Cronin


1 Answers

Define your functions in a helper and load them from the controller. That way you can reuse the functions in other views, as well.

like image 169
Christian Davén Avatar answered Apr 10 '26 19:04

Christian Davén



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!