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