Home > Software design >  PHP: Replace create_function in PHP 8
PHP: Replace create_function in PHP 8

Time:01-31

I need replace create_function() for something else

add_action( 'plugins_loaded', create_function( '', 'global $Gestor_Cadastros; $Gestor_Cadastros = new Gestor_Cadastros();' ) );

I don't know about this, what can I do?

CodePudding user response:

The create_function() function is considered obsolete as of PHP 7.2 and should be avoided for security reasons. It is recommended to use an anonymous closure instead:

add_action( 'plugins_loaded', function() {
   global $Gestor_Registers;
   $Gestor_Registers = new Gestor_Registers();
});
  • Related