String: Checking for Empty ValuesTag: basic, string Category: PHP Basicpost: 01 Feb 2008 read: 406 PHP String Tips: PHP have built in function name empty()for checking empty value. But, it is not good idea. Why? Because it will not work for variable have "0" value. PHP will treat "0" as false. So, it will return empty. But, we want "0" is exist, not empty. Solution? We can use combination isset() and trim() function for checking. The code like this:
The simple logic: use isset() to verify that exists, then use trim() function to trim whitespace from the edges. |
| | Give Your Opinion | Recommend |
|

