I work on CI 3.1.7 php 7.0 and when i upgrade my php version to 7.1.13 and 7.2 i got this error in Codeigniter.
Note: it will work fine in php 7.0.
controller code:
class Site extends CI_Controller {
public $data="";
function __construct(){
parent::__construct();
//var_dump($this->site_model->get_web_data(1));die();
$this->data["C_mobile_number"]=$this->site_model->get_web_data(1);
model code
function get_web_data($id){
$result=$this->db->where('drid',$id)
->get('web_data');
if($this->db->affected_rows() > 0){
$data=$result->result();
return $data[0]->data;
}else{
return "";
}
}
var_dump result : E:\wamp64\www\**\application\controllers\Site.php:9:string '+91.**********' (length=14)
In php 7.1 or higher i got this error
Severity: Warning
Message: Illegal string offset 'C_mobile_number'
Filename: controllers/Site.php Line Number: 10
Any salution?
Before $this->data["C_mobile_number"]=...
insert $this->data = [];
. This is initiated $this->data
as array;