PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
if (!empty($_POST['foo']) && (trim($_POST['foo'] != ''))
Is it always necessary to do it with the comparison operators? It just seems akward. If you don't use trim, a single space (or multiple) or other characters will be a value, so !empty() will return true.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Yeah, I suppose that's true. I can't think of a situation where I'd like to allow whitespace at the beginning or end of a string, besides passwords. Even then, if trim() is called when creating the password, and then for matching the hash, it will still match.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
scottayy wrote:Yeah, I suppose that's true. I can't think of a situation where I'd like to allow whitespace at the beginning or end of a string, besides passwords. Even then, if trim() is called when creating the password, and then for matching the hash, it will still match.
It'll also match if the user enters their password without the whitespace though, which is technically wrong.