Lisphp_Program::load PHP Method

load() public static method

public static load ( $file )
    public static function load($file)
    {
        if ($fp = fopen($file, 'r')) {
            for ($code = ''; !feof($fp); $code .= fread($fp, 8192)) {
            }
            fclose($fp);
            try {
                $program = new self($code);
            } catch (Lisphp_ParsingException $e) {
                throw new Lisphp_ParsingException($e->code, $e->offset, $file);
            }
            return $program;
        }
    }

Usage Example

Example #1
0
function balrog_front_controller($baseDir)
{
    $environment = Lisphp_Environment::full();
    $scope = new Lisphp_Scope($environment);
    $scope['require'] = new Lisphp_Runtime_PHPFunction(function ($file) use($scope) {
        $program = Lisphp_Program::load(__DIR__ . '/' . $file . '.lisphp');
        return $program->execute($scope);
    });
    $scope['base-dir'] = $baseDir;
    $filename = __DIR__ . '/front-controller.lisphp';
    $program = Lisphp_Program::load($filename);
    $program->execute($scope);
}
All Usage Examples Of Lisphp_Program::load