CodeIgniter Forums
Why can't I use trim() in CodeIgniter 3.0? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Why can't I use trim() in CodeIgniter 3.0? (/showthread.php?tid=62508)



Why can't I use trim() in CodeIgniter 3.0? - xietao0221 - 07-22-2015

Because of the version of apache and php, I cannot use CI's form_validation library and filter function, I have to write some native code to filter the special character. However, I cannot use trim() on model or controller, even though I add $this->load->library('string'). Anyone knows how to solve it? Or anyone give me some suggestion to do it without using CI's form validation. Thank you!


RE: Why can't I use trim() in CodeIgniter 3.0? - Wouter60 - 07-23-2015

The function trim() is a native php function, so it should work, whether you use CodeIgniter or not.
Please give us an example of your code that won't work.


RE: Why can't I use trim() in CodeIgniter 3.0? - xietao0221 - 07-23-2015

The code is pretty simple, $data['inputAddressLine1'] = trim($_POST['inputAddressLine1']); This line is in the controller, but when I use $data in the View($inputAddressLine1), the multiple white space cannot be removed, I am really confused with it.


RE: Why can't I use trim() in CodeIgniter 3.0? - mwhitney - 07-23-2015

If the version of Apache and PHP you are using is preventing you from using CI's form_validation library, I don't really know how we're going to be able to help you re-implement the library in whatever version of PHP you are using.

If trim() isn't removing whitespace, that implies that one of the following is true:
- the whitespace is inside the string, not on the right or left edge of the string
- the whitespace is something else which trim() won't remove by default (the manual tells you which 6 characters are interpreted as whitespace)
- trim() is removing the whitespace, but you're not looking at the result of trim()


RE: Why can't I use trim() in CodeIgniter 3.0? - InsiteFX - 07-23-2015

Try using CodeIgniters input.

PHP Code:
$this->input->post('something'); 



RE: Why can't I use trim() in CodeIgniter 3.0? - xietao0221 - 07-23-2015

(07-23-2015, 03:38 PM)InsiteFX Wrote: Try using CodeIgniters input.



PHP Code:
$this->input->post('something'); 

Still doesn't work, I have no idea. But without using CI, trim() works. I give up solving this problem, because if the apache does not allow me to use almost all useful library and function of CI, this framework is useless in another word. 
Thank you guys for all your help!


RE: Why can't I use trim() in CodeIgniter 3.0? - mwhitney - 07-24-2015

(07-23-2015, 05:00 PM)xietao0221 Wrote: Still doesn't work, I have no idea. But without using CI, trim() works. I give up solving this problem, because if the apache does not allow me to use almost all useful library and function of CI, this framework is useless in another word.  Thank you guys for all your help!

What version of Apache and PHP are you using? It really sounds like there's something else wrong here and you're just trying to work around a bigger issue that might be more easily fixed by taking it on directly.


RE: Why can't I use trim() in CodeIgniter 3.0? - Narf - 07-24-2015

I believe it's just a logical error in your code and you've shown none of it so far ...


RE: Why can't I use trim() in CodeIgniter 3.0? - skunkbad - 07-24-2015

What Narf said, and are you getting an error, a white screen, or what? Show something to us.


RE: Why can't I use trim() in CodeIgniter 3.0? - ignitedcms - 07-25-2015

This is what I call a chair to interface error. Quit blaming the framework Wink