Re: Should there be a `get_declared_enums()` function ?

From: Date: Sun, 18 Aug 2024 08:59:07 +0000
Subject: Re: Should there be a `get_declared_enums()` function ?
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-125041@lists.php.net to get a copy of this message
On 18 August 2024 05:46:09 BST, Mike Schinkel <mike@newclarity.net> wrote: >I know that those functions can be called as a function and return a value like the following: > >$return_value = include($path); You are right that it has a return value, but wrong to put its argument in parentheses. This will *not* do what you expect: $success = include($path) && somethingElse(); Because include is not actually a function, what is evaluated is $path && somethingElse(), then either include true or include false (which will of course fail). You instead need to write this: $success = (include $path) && somethingElse(); I thought I'd added this example to the manual, but now can't find it. Consequently, we can't just define optional parameters like we would a normal function. We *could* extend the syntax to allow "include $path, $whatever;" but it probably wouldn't feel very natural. It would be a syntax error to write "include($path, $whatever)" just as "echo $foo, $bar" is valid, but "echo($foo, $bar)" is not. Regards, Rowan Tommins [IMSoP]

« previous php.internals (#125041) next »