【发布时间】:2018-04-27 01:49:14
【问题描述】:
我在我的 codeigniter 控制器中这样做
public function getprice($origin,$destination){
$this->load->model("flights");
$query['data']=$this->flights->giveprice($origin,$destination); //model gives fine result
$this->output
->set_content_type('application/json')
->set_output(json_encode(array('foo' => $query['data']))); //data is printed correctly
}
我已经用确切的这个网址点击了这个网址:-
localhost/codeIgniter/index.php/booking/getprice?origin="Karachi"&destination="Lahore"
我得到这个作为回应:-
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>An uncaught Exception was encountered</h4>
<p>Type: ArgumentCountError</p>
<p>Message: Too few arguments to function Booking::getprice(), 0 passed in /opt/lampp/htdocs/codeIgniter/system/core/CodeIgniter.php on line 532 and exactly 2 expected</p>
<p>Filename: /opt/lampp/htdocs/codeIgniter/application/controllers/Booking.php</p>
<p>Line Number: 22</p>
<p>Backtrace:</p>
<p style="margin-left:10px">
File: /opt/lampp/htdocs/codeIgniter/index.php
<br />
Line: 315
<br />
Function: require_once
</p>
我的另一个不带参数的函数运行良好,但是当涉及参数(“GET”)时,它说“给出的论点太少”,我提供了 2 个参数。请纠正我做错的地方。
【问题讨论】:
标签: php json codeigniter get