How can I make the create_function() function in my application below according to 7.x?

Viewed 6

I have used create_function() in my application below.

1.code

    if (function_exists("awtLicense")) {
add_action("widgets_init", create_function("", "return register_widget(\"NumberWidget\");"));    
  1. code

        function get_domain($url)
    {
     $pieces = parse_url($url);
     $domain = isset($pieces["host"]) ? $pieces["host"] : "";
      if (preg_match("/(?P<domain>[a-z0-9][a-z0-9\\-]{1,63}\\.[a-z\\.]{2,6})\$/i", $domain, $regs)) {
     return $regs["domain"];
     }
     return false;
    }
    function awtLicence() {
    $site = $_SERVER['SERVER_NAME'];
    $site = 'http://' . $_SERVER['SERVER_NAME'];
    $site = get_domain($site);
    $key = 'AWT';
     return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $site, MCRYPT_MODE_CBC, md5(md5($key))));
    } 

But for PHP 7.x, create_function() and mcrypt_encrypt is deprecated.

How do I rewrite my code above for PHP 7.x?

0 Answers
Related