dongta5621 2017-11-01 13:51
浏览 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 19: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

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

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?