I realise strlen is the correct function to use, I'm just curious as to why this happens.
How come if PHP in I do echo count("");, it returns the value 1?
I'd have expected it to return 0, as opposed to 1.
I realise strlen is the correct function to use, I'm just curious as to why this happens.
How come if PHP in I do echo count("");, it returns the value 1?
I'd have expected it to return 0, as opposed to 1.
count is counting how many element there are. Here you got a string, so one element.
Please read the doc :
Returns the number of elements in array_or_countable. If the parameter is not an array or not an object with implemented Countable interface, 1 will be returned. There is one exception, if array_or_countable is NULL, 0 will be returned.