这个函数在PHP 7.4上运行良好,但是当我将服务器更新到php 8.1时,我得到了错误500内部服务器错误。请帮助
public function getTicketJsonBYNumber($mobile_number = null)<br />
{<br />
$this->load->model(array('website_model'));<br />
$booking_id_no = $this->website_model->getBookingIDByNumber($mobile_number);<br />
$ticket = $this->website_model->getPaidTicket($booking_id_no); <br />
$data = array(<br />
'pickup_trip_location' => $ticket->pickup_trip_location,<br />
'drop_trip_location' => $ticket->drop_trip_location,<br />
'passenger_name' => $ticket->passenger_name,<br />
);<br />
$this->output->set_header('Access-Control-Allow-Methods: GET');<br />
$this->output->set_header('Access-Control-Allow-Origin: *');<br />
$this->output<br />
->set_content_type('application/json')<br />
->set_output(json_encode($data));<br />
}
1条答案
按热度按时间f2uvfpb91#
在PHP 8.0中,
json_encode()
现在在遇到错误时返回false而不是空字符串,这可能会导致内部错误,为了修复它,请在PHP函数中添加适当的错误处理,我已经为您添加了它,这应该在PHP 8.0中正常工作。