-
- 19 Posts
I don’t really know if someone aware of this(maybe there was something)... although i ve studied buglist of rc-4 and didnt find anything about this issue...
It also can be the lack of knowledge - but i really hope it is not =))))
So the problem is...
If we return variable with include call - we get .’1’.
For example (found in tutorial n liked the idea very much) lets make snippet include.
$o=include $file;
$return $o;
Then we make the call of the snippet [[!include? file=`[[++core_path]]components/mycomp/mycomp.php`]]
In the end i get the work of mycomp.php .’1’,
when i change everything to one string
include $file;
everything works fine, i.e. problem in returning through variable,
also (i think another problem somehow connected with this one), got nothing through return statement...
I mean, when i launch snippet, which has somewhere in the end
return ’done’;
I got nothing (although tutorial examples are full of such calls)
echo ’done’;
works fine although =)
PS. Sorry for my bad english =)
That is because the return value of a successful "include" operation is 1. Include and require are not functions, they either include the file or they don’t. You do not need to return their return values, since these only indicate success or failure, and you’ll know soon enough if it fails for some reason!
-
- 24,544 Posts
If you want it to fail right away if the file isn’t found, you can use:
You can also test the return value and do something more graceful:
$0 = include $file;
if (! $0) {
return 'File not found';
}