tags:

views:

27

answers:

2

This works:

!function_exists('testfunc') and include("testfunc.php");

This will report syntax error:

!function_exists('testfunc') and unset($q);

Aren't they the same thing?

+1  A: 

unset has no return value and according to http://php.net/manual/en/function.include.php you can "return" from the included file (so it's not void :P)

...I'm pretty sure that's what it is

Terence Honles
Similarly, `1 and echo('6');`.
KennyTM
What if the included file doesn't have a `return` statement then,will it report error?
wamp
nope... it just works (AFAIK 'cause it is *able* to return something)
Terence Honles
So PHP doesn't care whether it **actually** returns something, but whether it's **able** to return something?
wamp
Not true. `include()` actually does return a `true` value when successful and a `false` value when unsuccessful. You can check the link that `Terence` gave you. View the description after Example #5. What `Terence` was trying to say is that the included file can use the `return` statement to control what value gets returned. So yes, PHP **does** care whether it **actually** returns something because if the function **can** return anything, it always does.
Joseph
thanks for the clarification Joseph (I should have tried to include something and see what was returned) (I didn't see what the default return values were in the docs (I didn't really look that hard though))
Terence Honles
A: 

unset is void, it returns no value.

include can return a value, which is the return value defined in the file included. might be bool, might be something else. In general it's not recomended to use it that way.

Am
you not reload your browser?
Terence Honles