$this->input->post('something'); trim the value etc. |
[eluser]searain[/eluser]
We would use $this->input->post('something'); a lot. And in 99% cases, I would like the value we get to be trimmed, and return '' of it does not exist (instead of return false as default. CIdeveloper has suggested Extending the Core Input Class. http://ellislab.com/forums/viewthread/178827/ I was thinking modifying his codes a little bit. Like the following, so in my application, whenever I call $this->input->post('something'), it will 1) return '' instead of false if it doesn't exist. 2) return trimmed value. if i call $this->input->post('something', true); then it will act like the ci default $this->input->post('something'); I am debating if I should extend the core class input. Other developers may get confused if they don't read the document. But how could I make an easy call that $this->input->post('something') get trimmed and return '' if it doesn't exist? I was thinking about extend the core input class, but instead override post function, i would write a mypost() function to do the same. But it seems cideveloper's approach (override post method) is more elegant. What is your advices? Thanks! Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
Welcome Guest, Not a member yet? Register Sign In |