Oh well, maybe it’s my ignorance, but PHP documentation about include statement says take care when comparing return value:
<?php
// won't work, evaluated as include(('vars.php') == 'OK'), i.e. include('')
if (include('vars.php') == 'OK') {
echo 'OK';
}
// works
if ((include 'vars.php') == 'OK') {
echo 'OK';
}
?>
But this is what i’ve experienced; boolean false in case of fail, int 1 if success:
$exists = 'Found.php';
var_dump((include $exists)); // Type is: int, value is: 1
$notexists = 'NotFound.php';
var_dump((include $notexists)); // Type is: boolean, value is: false
Is this my bad? Why returning value is inconsistent (meaning not always boolean, for example) and differs from PHP documentation?
Well this is exactly what the documentation states:
When it becomes inconsistent is when you actually return something in the included file,
e.g. in Found.php:
And then
It is also worth reading up on how booleans evaluate in PHP:
http://php.net/manual/en/language.types.boolean.php