Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从代码点火器调用Curl(ed)json内容_Php_Codeigniter - Fatal编程技术网

Php 从代码点火器调用Curl(ed)json内容

Php 从代码点火器调用Curl(ed)json内容,php,codeigniter,Php,Codeigniter,这是我在模型中的函数 <?php class Clothes_model extends CI_Model { public function __construct() { $this->load->database(); } public function get_clothes() { $url="http://192.168.0.105/ci/json_source/clothes.ph

这是我在模型中的函数

<?php
    class Clothes_model extends CI_Model {

    public function __construct()
    {
        $this->load->database();
    }

    public function get_clothes()
    {
        $url="http://192.168.0.105/ci/json_source/clothes.php";//clothes.php contain json data
        $data= this->curl->simple_get($url);
        $result = json_decode($data,true);
        return $result;
    }
}
尝试更改:

this->curl->simple_get($url);

并确保您的
$this->curl
有效

尝试更改:

this->curl->simple_get($url);


并确保你的
$this->curl
是有效的

我喜欢这个,而且对我有用

    $string=file_get_contents("proj-data/food_query.php"); //place where json file is
    $decoded=json_decode($string,TRUE);

我喜欢这个,为我工作

    $string=file_get_contents("proj-data/food_query.php"); //place where json file is
    $decoded=json_decode($string,TRUE);

$this->load->library('curl');对吗?而不是$this->load->database()//模型class@WayneTun您不需要在模型中加载库,只需在控制器中加载库,您可以在您的模型中使用$this->curl是否需要在服务器上安装php5 curl库?@WayneTun yes curl需要安装在服务器上才能工作$this->load->library('curl');对吗?而不是$this->load->database()//模型class@WayneTun您不需要在模型中加载库,只需在控制器中加载库,您可以在模型中使用$this->curl需要在服务器上安装php5 curl库吗?@WayneTun是的curl需要在服务器上安装才能工作我的服务器无法安装curl我的服务器无法安装curl