Re: [VOTE] First-class callable syntax

From: Date: Mon, 05 Jul 2021 15:13:12 +0000
Subject: Re: [VOTE] First-class callable syntax
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-115304@lists.php.net to get a copy of this message
On 05/07/2021 15:35, Nikita Popov wrote:
The actual echo syntax is echo "Foo". PHP allows you to write echo("Foo") in the same way it allows you to write echo((((("Foo"))))). Don't do it :)
Indeed. Note that this is valid: echo "hello", " ", "world"; But this is not: echo("hello", " ", "world"); I have in the past had a bug make it into production because the parentheses around a call to "include" were mis-placed because of this incorrect belief that it is "function-like": if ( include('some_file.php') && bar() ) Is equivalent to this (will always run bar(), then attempt to include either (string)true or (string)false): if ( include ('some_file.php' && bar()) ) When what was intended was this: if ( (include 'some_file.php') && bar() ) Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#115304) next »