gpt4 book ai didi

php - com_create_guid() 函数在服务器端出错,但在本地使用 php 时工作正常

转载 作者:IT王子 更新时间:2023-10-28 23:51:29 24 4
gpt4 key购买 nike

正在生成一个 php 文件中的 guid。我正在使用 com_create_guid()。它在本地主机上工作正常,但我在远程服务器中显示以下错误。

Fatal error:Call to undefined function com_create_guid() on line 6

我的代码是(仅引导部分)

$guid = com_create_guid();
echo $guid;

任何想法

最佳答案

您可以手动创建 GUID:

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;
}
}

用法:

$GUID = getGUID();
echo $GUID;

关注:

http://guid.us/GUID/PHP

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

关于php - com_create_guid() 函数在服务器端出错,但在本地使用 php 时工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18206851/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com