Re: [Discussion] Deprecate function sizeof()
| From: | Kalle Sommer Nielsen | Date: | Sat, 07 Mar 2015 19:42:34 +0000 |
| Subject: | Re: [Discussion] Deprecate function sizeof() | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-84413@lists.php.net to get a copy of this message | ||
Hi
2015-03-07 18:35 GMT+01:00 Sebastian B.-Hagensen <sbj.ml.read@gmail.com>:
> Hi,
> I don't think the alias make sense and is really misleading and I've
> seen sizeof("abc"); often enough (Don't get me wrong that's equally
> bad with count, but sizeof encourages that usage, imo).
> Having two functions that do exactly the same using different names
> for no good reason (one of them referring to a different operation in
> a more popular language) isn't optimal. Code using a deprecated sizeof
> call is trivial to fix.
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.
--
regards,
Kalle Sommer Nielsen
kalle@php.net