On Mon, Jul 8, 2019 at 4:53 PM Claude Pache <claude.pa...@gmail.com> wrote:
> > > Le 8 juil. 2019 à 15:20, Christoph M. Becker <cmbecke...@gmx.de> a > écrit : > > > > FTR, there is already substr_compare(). > > `substr_compare()` (as well as `strncmp()` which I am currently using in > lieu of `str_starts_with()`) forces you to provides the substring and the > length of the substring, instead of just the substring: > > substr_compare('foobarbaz', 'foo', 0, 3) === 0 > strncmp('foobarbaz', 'foo', 3) === 0 > str_starts_with('foobarbaz', 'foo') Explaining my 'no' vote (I was quite undecided on it). Generally, I think it's a Good Thing to have startsWith/endsWith functions in PHP. However, several things made me eventually vote 'no' on this proposal at this point in time: 1. I'm still hopeful that we would one day clean up the global namespace by creating a new set of namespacecd functions that would be consistent in naming, semantics and argument order. It feels wrong to add more to the mess right now... 2. Unless I'm mistaken, these functions introduce a new kind of notation for case insensitivity that we don't presently have in PHP (_ci()). Maybe it's a good option, but having a new 3rd or 4th notation feels wrong. 3. Given one can relatively easily (if not as elegantly) use substr_compare() to implement startsWith()/endsWith(), the added value doesn't appear to me to be worth the downsides. Zeev >