Why use trim () to trim user input data? I have seen many programs use trim to trim user input data,
Why?
The introduction in the book says that it is for security.
I am wondering, which of the following is a detailed explanation?
Reply to discussion (solution)
Trim can be ???? Space.
If ?? Entered ?? Yes
$ Data = '';
So? Use if ($ data = '')? Returns false, because? Use? Yes? Incoming ??, Only no? Is a space.
But me ?? Check if? All input ?? All are spaces, right? Intentionally? Of ,??? Null character? .
So trim ($ data ?? Space? After division, if? If there are characters, it means to use? Yes? Incoming ??, In addition, you can? Space used? Division.
Example $ data = 'aaa ';
Echo trim ($ data); // aaa
It has nothing to do with security and does not need to be used.
When registering and logging in, it is inevitable that multiple spaces will be mistakenly operated. at least remove the first and last spaces.