> On Aug 18, 2024, at 4:59 AM, Rowan Tommins [IMSoP] <imsop....@rwec.co.uk> 
> wrote:
> 
> On 18 August 2024 05:46:09 BST, Mike Schinkel <m...@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.
Hi Rowan,

Thank you for confirming the nature of include, et. al.

So, if the functionality to be notified via a callback for all symbols loaded 
is a desired feature by other than me and maybe Juliette then the best approach 
I've come up with is to add an `spl_autoload_callback()` function that can both 
get and set the callback to be called after include or its 3 other friends are 
called.  Anyone (else?) disagree?

-Mike

Reply via email to