换成PHP 7.2时如何修复create_function

时间:2019-01-14 21:02:00

标签: php php-7.2

我看到人们在帮助重写匿名功能。 但是我真的不知道怎么做:

  

已弃用:函数create_function()在第149行的/mnt/web110/c3/68/51799968/htdocs/portfolio2017/wp-content/themes/clean-photo-wp-modified/internal/includes.php中已弃用< / p>

方法:

/**
 * Safe file inclusion
 *
 * @param $path
 */
public static function include_isolated( $path ) {
    if ( ! self::$include_isolated_callable ) {
        self::$include_isolated_callable = create_function( '$path', 'include $path;' );
    }

    call_user_func( self::$include_isolated_callable, $path );
}

1 个答案:

答案 0 :(得分:2)

self::$include_isolated_callable = function($path) { include $path; };

http://php.net/manual/en/functions.anonymous.php