public static function prepare($php, $tmpDir = null, $delete = true) {
        $php = "<?php $php ?>";

        if (!ini_get('allow_url_include') || !ini_get('allow_url_fopen')) {
            if (!is_string($tmpDir) || !is_dir($tmpDir)) {
                $tmpDir = sys_get_temp_dir();
            }
        }

        if (is_dir($tmpDir)) {
            $fn = tempnam($tmpDir, 'lci_');
            if (!$fn) {
                error_log("Can not generate tmp file under $tmpDir!!\n");
                return false;
            }
            if (!file_put_contents($fn, $php)) {
                error_log("Can not include saved temp php code from $fn, you should add $tmpDir into open_basedir!!\n");
                return false;
            }

            $phpfunc = include($fn);

            if ($delete) {
                unlink($fn);
            }

            return $phpfunc;
        }

        return include('data://text/plain,' . urlencode($php));
    }
public static function prepare($php, $tmpDir = null, $delete = true) {
        $php = "<?php $php ?>";

        if (!ini_get('allow_url_include') || !ini_get('allow_url_fopen')) {
            if (!is_string($tmpDir) || !is_dir($tmpDir)) {
                $tmpDir = sys_get_temp_dir();
            }
        }

        if (is_dir($tmpDir)) {
            $fn = tempnam($tmpDir, 'lci_');
            if (!$fn) {
                error_log("Can not generate tmp file under $tmpDir!!\n");
                return false;
            }
            if (!file_put_contents($fn, $php)) {
                error_log("Can not include saved temp php code from $fn, you should add $tmpDir into open_basedir!!\n");
                return false;
            }

            $phpfunc = include($fn);

            if ($delete) {
                unlink($fn);
            }

            return $phpfunc;
        }

        return include('data://text/plain,' . urlencode($php));
    }
public static function prepare ( $ php , $ tmpDir = null , $ delete = true ) { $ php = "<?php $php ?>" ; if ( ! ini_get ( 'allow_url_include' ) || ! ini_get ( 'allow_url_fopen' ) ) { if ( ! is_string ( $ tmpDir ) || ! is_dir ( $ tmpDir ) ) { $ tmpDir = sys_get_temp_dir ( ) ; } } if ( is_dir ( $ tmpDir ) ) { $ fn = tempnam ( $ tmpDir , 'lci_' ) ; if ( ! $ fn ) { error_log ( "Can not generate tmp file under $tmpDir!!\n" ) ; return false ; } if ( ! file_put_contents ( $ fn , $ php ) ) { error_log ( "Can not include saved temp php code from $fn, you should add $tmpDir into open_basedir!!\n" ) ; return false ; } $ phpfunc = include ( $ fn ) ; if ( $ delete ) { unlink ( $ fn ) ; } return $ phpfunc ; } return include ( 'data://text/plain,' . urlencode ( $ php ) ) ; }
Get a working render function by a string of PHP code. This method may requires php setting allow_url_include=1 and allow_url_fopen=1 , or access right to tmp file system.

@param string      $php PHP code
@param string|null $tmpDir Optional, change temp directory for php include file saved by prepare() when cannot include PHP code with data:// format.
@param boolean     $delete Optional, delete temp php file when set to tru. Default is true, set it to false for debug propose

@return Closure|false result of include()

@deprecated
Get a working render function by a string of PHP code . This method may requires php setting allow_url_include = 1 and allow_url_fopen = 1 or access right to tmp file system .