On 7 March 2015 at 20:42, Kalle Sommer Nielsen <ka...@php.net> wrote:

> Hi
>
> Well we could make count()/sizeof() work for strings, so that if:
> C:\> php -r "echo sizeof('abc');"
> 3
>
> although it would not really accomplish much imo., I think it is more
> of what background you come from that makes the most sense to me, I
> got into PHP before C and I enjoy sizeof more for array sizes than
> count, but that is just a pure preference.
>

Maybe count() and sizeof() should retain original functionality for the
sake of compatibility, but should emit warning if used on non-array/object
variables?
This seems like a gentle way to steer users towards using strlen() on
strings.

Using sizeof(null) seems somewhat legitimate, but sizeof("asdf") seems like
a newbie mistake at counting characters in a string.

b.

PS: All above assumes the functionality of sizeof() does not change. If
sizeof() functionality should be changed to be more aligned with it's C
counterpart, then above argument does not stand.

Reply via email to