Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95107 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7868 invoked from network); 13 Aug 2016 02:29:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Aug 2016 02:29:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=bishop.bettini@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=bishop.bettini@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.41 as permitted sender) X-PHP-List-Original-Sender: bishop.bettini@gmail.com X-Host-Fingerprint: 209.85.218.41 mail-oi0-f41.google.com Received: from [209.85.218.41] ([209.85.218.41:36570] helo=mail-oi0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 09/46-55605-F168EA75 for ; Fri, 12 Aug 2016 22:29:52 -0400 Received: by mail-oi0-f41.google.com with SMTP id f189so4433480oig.3 for ; Fri, 12 Aug 2016 19:29:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:from:date :message-id:subject:to:cc; bh=noOfcnMNj3rAtshCv2Xyov2q3rUc770AxEOLFZfEMnc=; b=dE5SMcUHGs274+7QilmNX7gTg4F811OhK3BPBLLt9QHunRTlXXbSgAfFn8LXas3ilr iEX0UaFUqesikX7wWe1sJSHLPagapY3n4nueOgMcixp5Lul2J4h4hmf5f0Hb/7l1wClP vVPm7/R+JU0JKFw74jrm3Fp50QTUCpyS+pQkV9vVDY9eeT1/zb3kB1QzMRYw7fjetgAi Qn7QqnQL8273MRxn9ES5hYRFvkk70PGaheYWXlvHxlzQmt6grv32dviIWSU1OpqNrW1H QGEttvdxEJ9C52o8zRx1zzM+BfshLIgpxSFCdSTZ9N/yrikkMqYD9WT9ARKDWgvsMNOD GIrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:sender:in-reply-to :references:from:date:message-id:subject:to:cc; bh=noOfcnMNj3rAtshCv2Xyov2q3rUc770AxEOLFZfEMnc=; b=UllENG51jJZ6D/xz/MebX9U1WhdHdJEWDP1DC6Y6Z2uhVyIouOjZKNZyr/s52h8J5o Pf+jAxo6DiRWkihaqV73SAcL97y24WkfEzaHBS3+nD4H/276jdU/YH6iDyoohCveHHnt +7z5xiTFDvasUxUd6OeUbqUqZQWboaqvsUUF5qSNu5C9pSJ9aZvTUyQBodqSRXlcp4bQ 8Yq50VabHcujOjiwVBKZ5AuoVHKT3mXFk1uXr3xtxgvD4u5c9wHbgDoekhzesYYhkp91 FW0eN10tici8Lyp0b8fszenLtdVnYM3VyAILxpJ9p+T9mrgB6cVzspncaATHvUhCN0/b hABg== X-Gm-Message-State: AEkoouv239ug8CAnYd9yVm5TEjSYMn+kK8QWUry5s/xPpEG4sHDB0gwPC2Ce8Z3aDFI0SU1CfmsW96q+8xYfzw== X-Received: by 10.157.51.124 with SMTP id u57mr6102981otd.25.1471055388808; Fri, 12 Aug 2016 19:29:48 -0700 (PDT) MIME-Version: 1.0 Reply-To: bishop@php.net Sender: bishop.bettini@gmail.com Received: by 10.157.11.214 with HTTP; Fri, 12 Aug 2016 19:29:18 -0700 (PDT) In-Reply-To: References: <8442f1fa5544b2ca03e7cebbc64e8e5c@wkhudgins.info> Date: Fri, 12 Aug 2016 22:29:18 -0400 X-Google-Sender-Auth: lvk2gGj4LS1wjidAgKMf6rdTUrM Message-ID: To: will@wkhudgins.info Cc: PHP internals Content-Type: multipart/alternative; boundary=001a11415524e51bf80539eac525 Subject: Re: [PHP-DEV] RFC Posted for str_begins and str_ends functions From: bishop@php.net (Bishop Bettini) --001a11415524e51bf80539eac525 Content-Type: text/plain; charset=UTF-8 On Fri, Aug 12, 2016 at 8:37 PM, wrote: > I've updated the RFC to reflect the discussion here and on github. You may > see it at > https://wiki.php.net/rfc/add_str_begin_and_end_functions . You can see > the github PR at https://github.com/php/php-src/pull/2049 . > > The motivation for these changes was to maximize consistency between the > proposed functions and existing PHP string functions. The goal is to make > these functions feel natural and add functionality to the language without > cluttering it up. > Generally, +1. A few thoughts. First, the RFC refers to these working on "characters". I assume you mean ASCII characters and these actually work strictly on bytes. Working on "characters" would be more in-line for a multi-byte extension. Would you please clarify this point? Second, and related to the multi-byte issue: do the case insensitive versions honor case-folding in a multi-byte fashion? Either way, it's probably a good idea to separate the vote between the sensitive and insensitive versions because this is fundamentally a different, and perhaps more contentious, question. Third, perhaps these functions could provide more information than just yes/no. Return boolean TRUE if and only if the needle completely begins/ends the haystack, otherwise return INT representing the length in common. Yes, that'll probably be a trap for new developers who don't honor ===, but that could be illuminated in docs. Formally: boolean|int str_begin(string $needle, string $haystack) boolean|int str_end(string $needle, string $haystack) For example: str_begin('http://', 'http://example.com') === true str_begin('http://', 'https://example.com') === 4 Finally, since the RFC will fuel the final documentation, it might be a good idea to use needle/haystack terminology in the function signatures for some kind of consistency. --001a11415524e51bf80539eac525--