1

这是我在模型中的功能

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

这是我的控制器

<?php
class Clothes extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->model('clothes_model');
    }

    public function view($result)
    {
        $data['clothes_item'] = $this->clothes_model->get_clothes();

        if (empty($data['clothes_item']))
        {
            show_404();
        }

        $data['title'] = $data['clothes_item']['title'];

        $this->load->view('templates/header', $data);
        $this->load->view('clothes/view', $data);
        $this->load->view('templates/footer');
    }
}

当我尝试运行时出现此错误

解析错误:语法错误,第 12 行 /var/www/ci/application/models/clothes_model.php 中的意外 T_OBJECT_OPERATOR

有什么不对的吗?

4

2 回答 2

1

尝试改变:

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

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

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

于 2013-02-08T04:11:46.323 回答
0

我确实喜欢这个并且为我工作

    $string=file_get_contents("proj-data/food_query.php"); //place where json file is
    $decoded=json_decode($string,TRUE);
于 2013-02-16T20:17:28.897 回答