dongta5621 2017-11-01 05:51 采纳率: 0%
浏览 196
已采纳

Laravel 5.4调用未定义的函数App \ iconv()

I have uploaded my project to a server, and now it is giving me problems, which can be ?, in local the project runs perfectly. this is the code of my function

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

the error is

Call to undefined function App\iconv() in this line

    $wm_string = iconv("windows-1251", "UTF-8", $data);

can be this a server problem? or maybe I must to download some package to my project?

展开全部

  • 写回答

1条回答 默认 最新

  • douyang5943 2017-11-01 11:33
    关注

    You may need to ask your hosting provider to give/install PHP compiled with iconv. Because by default php comes with iconv unless explicitly compiled without it.

    This extension is enabled by default, although it may be disabled by compiling with --without-iconv .

    iconv: http://php.net/manual/en/book.iconv.php

    iconv installation: http://php.net/manual/en/iconv.installation.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部