Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117377 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 71331 invoked from network); 18 Mar 2022 18:30:50 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Mar 2022 18:30:50 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 639831804F8 for ; Fri, 18 Mar 2022 12:56:23 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 18 Mar 2022 12:56:22 -0700 (PDT) Received: by mail-ej1-f49.google.com with SMTP id yy13so19041910ejb.2 for ; Fri, 18 Mar 2022 12:56:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mWT6AaoGxs+o43ANW6vIotn1gsxKcIxaSR8Hf2POuSg=; b=QvFQX628l+Uq3Yvj0TgE0z658IZZzs2UmqE1CS1qhPf/5z3N1qV+8wOq/wEmzbd1ds sxvYMwE7f1iiWbYT/1+5CWMoq4AU/twwaoXLkIKTHRDvZGwQB1aDClUSPUjhc8CmLZTp 0q/pU4COIx4hbPWWoALFEpi4GzFh3ufiqJCvWoLcuj/HtHZlaKNQe4HSDOdHBMgakpdE tqwlkkXJ0mVa9FGXeSmN4PKXqAw9n7lNzY0R/D5JGcYS5dwKwue3rITcuna1dwer1OKG PODAwYbhEA3dLxkGIabDvtwhkeBLfraq8dwoiDwXpOWcXFxTpE9rVuS+CbKEdLRRi1e3 fSFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mWT6AaoGxs+o43ANW6vIotn1gsxKcIxaSR8Hf2POuSg=; b=Fjxde2P9WAeEO3P5eQV7tEkGLpfeQO5ZL8qmoYvpIRjn6mz0vOBs1L6OPW55MIR0Ca /pMBj5iLciaq4JBZ0Zx4hVNstqjXWxnRfFk/JTAnXGSfKxtzVIjGZViEtGB2FBWH+RNR lD4tuuhXvlUcz0T5bIX3IQQg40KaJCXkc26Xob+0ArW1G2lktAQifqnI91jXdenJwmOV mAIn/9vAfm2qy7BzKGvLosGzWW6EbOA16kpsROhj271zVACAUkJhaWH/jEvdbSjKbDa7 d5GgbyIt6fXpjXFRNoZ8masZCisWjZA5J4d0S0aMEEbRCPqAdEvePZjcWhF1bL3uwoiC 22Tw== X-Gm-Message-State: AOAM531680aAcSbdRrLlAYKg3krDtv1yiE9DI7w93PvKrM5u6O2YaGck SCfppyVe3KYRYWqECvjz85o2Ouok9hqxLGEUzq/XGhoAFMU= X-Google-Smtp-Source: ABdhPJxNPcp+quMiC+tIWodt5IQnx65wPPEd/Dn2JffRBgYaO5ZefBqG4igB9OoMyCQ9POFPBYN/wt76hPcxKkTz3LQ= X-Received: by 2002:a17:906:7706:b0:6d6:e521:5471 with SMTP id q6-20020a170906770600b006d6e5215471mr10440266ejm.387.1647633381637; Fri, 18 Mar 2022 12:56:21 -0700 (PDT) MIME-Version: 1.0 References: <4AC60E84-B2AD-43F4-9B72-92604FC7BD41@gmail.com> In-Reply-To: Date: Fri, 18 Mar 2022 20:55:45 +0100 Message-ID: To: Theodore Brown Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000006ec35705da838a4f" Subject: Re: [PHP-DEV] [RFC][Under discussion] Arbitrary string interpolation From: divinity76@gmail.com (Hans Henrik Bergan) --0000000000006ec35705da838a4f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable i'd write it as $name =3D "Theodore Brown"; echo "{$name} has a length of " . strlen ( $name ) . "."; On Fri, 18 Mar 2022 at 05:49, Theodore Brown wrote= : > On Thu, Mar 17, 2022 at 5:40 PM Tobias Nyholm > wrote: > > > On Thu, 17 Mar 2022, 23:27 Ilija Tovilo, wrote= : > > > >> Hi everyone > >> > >> I'd like to start discussion on a new RFC for arbitrary string > >> interpolation. > >> https://wiki.php.net/rfc/arbitrary_string_interpolation > >> > >> Let me know what you think. > > > > That is a cool idea. > > But I am not a big fan of having code in strings. > > Wouldn=E2=80=99t this open the door to all kinds of new attacks? > > Do you have an example of a new kind of attack this would allow? > The proposal doesn't enable interpolation of strings coming from > a database or user input - it only applies to string literals > directly in PHP code. > > Personally I'm really looking forward to having this functionality. > Just a couple days ago I wanted to call a function in an interpolated > string, and it was really annoying to have to wrap the function in a > closure in order to use it. > > If this RFC is accepted I'd be able to replace code like this: > > $name =3D "Theodore Brown"; > $strlen =3D fn(string $string): int =3D> strlen($string); > echo "{$name} has a length of {$strlen($name)}."; > > with > > $name =3D "Theodore Brown"; > echo "{$name} has a length of {$:strlen($name)}."; > > > Sincerely, > > Theodore > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > --0000000000006ec35705da838a4f--