繁体   English   中英

重写PHP代码版本5.3及以上版本与5.2版本兼容

[英]re-writing php code version 5.3 and above compatible with version 5.2

我的主机使用的是旧版本的php 5.2,由于这段代码列表给出了解析错误,同时提出了如何兼容5.2版本的建议,它在我的本地服务器版本5.3中运行良好

  function getRequestedTests($labref) {
        $this->db->select('name');
        $this->db->from('tests t');
        $this->db->join('request_details rd', 't.id=rd.test_id');
        $this->db->where('rd.request_id', $labref);
        $this->db->order_by('name', 'desc');
        $query = $this->db->get();
        $result = $query->result();

       //problem starts here with the array_map()

        $output = array_map(function ($object) {
                    return $object->name;
                }, $result);
        return $tests = implode(', ', $output);
    }
function my_arr_map($object) {
  return $object->name;
}

function getRequestedTests($labref) {
  $this->db->select('name');
  $this->db->from('tests t');
  $this->db->join('request_details rd', 't.id=rd.test_id');
  $this->db->where('rd.request_id', $labref);
  $this->db->order_by('name', 'desc');
  $query = $this->db->get();
  $result = $query->result();

  //problem starts here with the array_map()
  $output = array_map(array($this, 'my_arr_map'), $result);
  return $tests = implode(', ', $output);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM