Re: [Discussion] Deprecate function sizeof()
| From: | Bostjan Skufca | Date: | Sat, 07 Mar 2015 20:02:35 +0000 |
| Subject: | Re: [Discussion] Deprecate function sizeof() | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-84414@lists.php.net to get a copy of this message | ||
On 7 March 2015 at 20:42, Kalle Sommer Nielsen <kalle@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.