Solar comes with two static utility classes for file and directory functions. We won't go over all their methods in detail, but they include:
Use the Solar_File::load() method to include a file inside its own limited scope. This allows you to include files but not pollute the current scope with the variables from the included file.
For example, say you have this "main" script:
<?php
$var = 'foo';
include 'script.php';
echo $var;
?>
If 'script.php' sets the value of $var for itself, that value will override the value from the main script, which can lead to unexpected behavior. If you want to make sure that 'script.php' executes in its own separate scope, use Solar_File::load() instead of include() or require():
<?php
$var = 'foo';
Solar_File::load('script.php');
echo $var;
?>
Now $var will remain the same before and after the inclusion of script.php (unless script.php calls global to make $var global).
As with include() and require, you can accept return values from the file you run:
<?php
$result = Solar_File::load('script.php');
?>
If the last line of script.php is a return value, $result will reflect that value.