PHP: using empty() for empty string?

前端 未结 3 1603
心在旅途
心在旅途 2020-12-10 16:38

I recently discovered this interesting article by Deceze.
But I\'m a bit confused by one of its advises:

never use empty or isset for variables th

3条回答
  •  我在风中等你
    2020-12-10 17:03

    What he means is if you want to check if the string is empty then empty won't do that. Empty can mean false, 0, null. Anything 'falsy'.

    E.g. these are all true:

    If you want to check if the string is an empty string you should do this check for '':

提交回复
热议问题