How to fix create_function when swapping to PHP 7.2 [duplicate]

梦想与她 提交于 2019-12-13 22:48:37

问题


I saw people helping on rewriting to anonymous function. But I really don't know how:

Deprecated: Function create_function() is deprecated in /mnt/web110/c3/68/51799968/htdocs/portfolio2017/wp-content/themes/clean-photo-wp-modified/internal/includes.php on line 149

Method:

/**
 * 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:


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

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



来源:https://stackoverflow.com/questions/54189121/how-to-fix-create-function-when-swapping-to-php-7-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!