Re: [RFC][Under discussion] Arbitrary string interpolation

From: Date: Fri, 25 Mar 2022 14:38:08 +0000
Subject: Re: [RFC][Under discussion] Arbitrary string interpolation
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-117426@lists.php.net to get a copy of this message
Hi Ilija I find that sprintf() is easier to read in most cases. One reason for this is that the text is separated from the code. It's also easier to review for humans and linters. The strtoupper example would look like this with sprintf: $world = 'world'; echo sprintf('Hello %s!', strtoupper($world)); Longer examples can be nicely split in multiple lines: echo sprintf( 'Received HTTP status code %d (reason phrase: %s)', $response->getStatusCode(), $response->getReasonPhrase(), ); And this also works with heredoc: echo sprintf( <<<'HTML' <html> <head> <title>%s</title> </head> </html> HTML, htmlspecialchars($title), ); -- Arnaud On jeudi 17 mars 2022 23:27:30 CET 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. > > Ilija

« previous php.internals (#117426) next »