PHP: Fatalerror: Calltoundefinedfunctioncom

Source: Internet
Author: User
The execution in the local Windows environment is normal, and a fatal error occurs on the Linux Server: Fatalerror: Calltoundefinedfunctioncom_create_guid (). The reason is that the PHP version of the server is high (5.4) and no built-in support for the com_create_guid () function, see the PHP official website installation instructions (php. netmanualencom. insta

The execution in the local Windows environment is normal, and a Fatal error occurs on the Linux Server: Fatal error: Call to undefined function com_create_guid () because the PHP version on the server is higher (5.4 ), no built-in support for the com_create_guid () function, see the PHP official website installation instructions (http://php.net/manual/en/com.insta

The local Windows environment runs normally and a fatal error occurs on the Linux Server:

Fatal error: Call to undefined function com_create_guid ()


The reason is that the PHP version of the server is relatively high (5.4) and does not have built-in support for the com_create_guid () function,

See PHP official website installation instructions (http://php.net/manual/en/com.installation.php ):

"From PHP 5.4.5, COM and DOTNET is no longer built into the php core. You have to add COM support in php.ini"

Therefore, you can either add the com Extension in php. ini or modify the Implementation of The GUID function to be compatible with various PHP versions, as shown below:

function getGUID(){    if (function_exists('com_create_guid')){        return com_create_guid();    }else{        mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.        $charid = strtoupper(md5(uniqid(rand(), true)));        $hyphen = chr(45);// "-"        $uuid = chr(123)// "{"            .substr($charid, 0, 8).$hyphen            .substr($charid, 8, 4).$hyphen            .substr($charid,12, 4).$hyphen            .substr($charid,16, 4).$hyphen            .substr($charid,20,12)            .chr(125);// "}"        return $uuid;    }}

Reference link:

Http://php.net/manual/en/function.com-create-guid.php


By iefreer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.