Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106176 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 47717 invoked from network); 8 Jul 2019 17:16:30 -0000 Received: from unknown (HELO tbjjbihbhebb.turbo-smtp.net) (199.187.174.11) by pb1.pair.com with SMTP; 8 Jul 2019 17:16:30 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=php.net; s=turbo-smtp; x=1563201355; h=DomainKey-Signature:Received: Received:MIME-Version:References:In-Reply-To:From:Date: Message-ID:Subject:To:Cc:Content-Type; bh=RS+q3xeknmikB4PeWJOPOT jIeKEs7q4ZW70gpqKcyW0=; b=f0qx5kW0OgtfpNTjz72kayVXTc5U7na8ByS13f cpK84PzazRewRY+wFt1NH54Wdn8wu+25fjMdo/uN7EvGZiNwzP5XEQOT+u4tEg58 yRLP8xK7/kYv6EAAZI8Za33rhyCaUL62j51iniQD9/blO+Opg0djG4XrxOHpwDyS oh85c= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=turbo-smtp; d=php.net; h=Received:Received:X-TurboSMTP-Tracking:X-Gm-Message-State:X-Google-Smtp-Source:X-Received:MIME-Version:References:In-Reply-To:From:Date:X-Gmail-Original-Message-Id:Message-ID:Subject:To:Cc:Content-Type; b=VuRKP158hZvbg0oaia8aoRN3eSqjsVNbbMxTfOf5lqMaTabn6tbV8krQspTbko HQuWD7cJCn6s9oYWEIHR3uFexEN3b8r1GkauhTW9XhKvmRsllL3TVIdqrQKR3rWe a0bUkG/YFFODvRpwsNv6wJID9GjikTuvOIHoP850h3jlM=; Received: (qmail 740 invoked from network); 8 Jul 2019 14:35:55 -0000 Received: X-TurboSMTP-Tracking: 5146873199 X-Gm-Message-State: APjAAAXhGra0YDnyRVZysVb506GmJCQeE12J7+qFgP/GQGtk2gh+wGdV pj5MR5gFcVL6ntHgXus1GRSMxX8HCqgEcBFhyhg= X-Google-Smtp-Source: APXvYqzeMlYLE+UCLipchSFn8zLJa2CzYKs5wdBLwNCJtgUDu8PvisYsVNnYPAcTNHFGeD+oGXK0sWoATu5XOY7SfVo= X-Received: by 2002:a05:620a:124f:: with SMTP id a15mr14846332qkl.173.1562596554934; Mon, 08 Jul 2019 07:35:54 -0700 (PDT) MIME-Version: 1.0 References: <1562591120.659818.23020.47476@mail.rambler.ru> <7ff385f1-b86d-e56d-4133-e2f101afa13e@gmx.de> In-Reply-To: Date: Mon, 8 Jul 2019 17:35:43 +0300 X-Gmail-Original-Message-Id: Message-ID: To: Claude Pache Cc: "Christoph M. Becker" , Andrew Gromov , internals , Marco Pivetta Content-Type: multipart/alternative; boundary="000000000000958d28058d2c5c52" Subject: Re: [PHP-DEV] Re: [VOTE] Voting opens for str_starts_with and ends_with functions From: zeev@php.net (Zeev Suraski) --000000000000958d28058d2c5c52 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jul 8, 2019 at 4:53 PM Claude Pache wrote: > > > Le 8 juil. 2019 =C3=A0 15:20, Christoph M. Becker a > =C3=A9crit : > > > > 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) =3D=3D=3D 0 > strncmp('foobarbaz', 'foo', 3) =3D=3D=3D 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 > --000000000000958d28058d2c5c52--