【发布时间】:2017-11-01 13:51:10
【问题描述】:
我已将我的项目上传到服务器,现在它给我带来了问题,可能是?,在本地项目运行完美。这是我的函数的代码
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Gateway extends Model
{
function _doPost($query) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://secure.nmi.com/api/transact.php");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_POST, 1);
if (!($data = curl_exec($ch))) {
return ERROR;
}
$wm_string = iconv("windows-1251", "UTF-8", $data);
parse_str(urldecode($wm_string), $result);
$data=json_encode($result, JSON_UNESCAPED_UNICODE);
curl_close($ch);
unset($ch);
$this->datos=$data;
return $this->datos;
}
}
错误是
调用未定义函数 App\iconv() 在这一行
$wm_string = iconv("windows-1251", "UTF-8", $data);
这可能是服务器问题吗?或者我必须下载一些包到我的项目中?
【问题讨论】:
-
确保您的电脑支持
iconv。你有什么——mac、win、linux? -
问题出现在服务器上,在我的电脑上工作正常,我有windows
-
所以你的服务器没有
iconv支持。 -
好的,那么我必须联系支持人员,我不必实施一些包来解决这个问题?
-
它是一个 php 扩展。您对服务器有 root 访问权限还是共享主机?