Why Trim function saves money
The answer simply: because it saves developer’s time.
In one of the php/Mysql websites I faced a problem with the sort order of some multilingual data. Usually when someone sort order such column, they get the English text first then the other languages like Arabic:
English text 1
English text 2
نص عربي 1
نص عربي 2
But what I have got was something like:
نص عربي 2
English text 2
English text 1
نص عربي 1
Actually some previous transportation processes of the database as well the high distortion of the sorted data made me thought that I have an encoding problem.
After 3 hours of work, trying to check the original encoding of data, I suddenly found that the web admin enters white spaces at the beginning of the entry very frequently. Although this made me smiling, as it saved me from falling in the hell of double-encoding problems, it pushed me to put a new ‘Must’ on my programming practices rules list.
The rule is the use of trim() function wherever the user has to enter data.
hi??