I have added PHP7 to my local server and I got this error:
Message: Array to string conversion Filename: libraries/Data_views_array.php Line Number: 59
data = $this->CI->$this_data[0]->$method($pass_var);
I found this post: PHP Notice: Array to string conversion only on PHP 7 and I changed my code to:
data = $this->CI->$this_data[0]->{$method($pass_var)};
but I got a different error:
Message: Call to undefined function get_page_id()
Everything works in PHP 5.6 and I don't know how to make it work in PHP 7.
Please help.
class Data_views_array {
var $CI;
public function __construct() {
$this->CI =& get_instance();
}
public function action_per_module($array_modules) {
$array_to_display = array();
$array_view_data = array();
if (!$array_modules) {
return false;
}
else {
while (list($key, $this_data) = each($array_modules)) {
/*
* $this_data[0] - is the controller name
* loading this model
*/
$this->CI->load->library($this_data[0]);
if ($this_data[2] == 'NULL') {
/*
* if there are no arguments (method and passing variable)
* the model is called
*/
$data = $this->CI->$this_data[0];
}
else {
/*
* getting method and passing variable from arguments
*/
//echo $this_data[2]. " - json<br>";
$obj = json_decode($this_data[2]);
$method = key(get_object_vars($obj));
//echo $method. " - method<br>";
$pass_var = $obj->$method;
/*
* getting data for view
*/
$data = $this->CI->$this_data[0]->$method($pass_var);
}
/*
* name of the View
*/
$view = $this_data[1];
/*
* adding the pair of View to the $array_view_data
*/
array_push($array_view_data, $view);
array_push($array_view_data, $data);
/*
* passing View Array to Display array
*/
array_push($array_to_display, $array_view_data);
/*
* clear the array of the pair of View and passing variable
*/
unset($array_view_data);
$array_view_data = array();
}
}
return $array_to_display;
}
}
The first Class that is called - $this_data[0]== page_title_display from library has method: get_page_id($page_id). This class gets the Title of the page. Why the same script works in PHP 5.6 and it does not work in PHP 7? Why the get_page_id function is found in PHP 5.6 but not in PHP 7?
class Page_title_display {
var $CI;
public function __construct(){
$this->CI =& get_instance();
}
public function get_page_id($page_id) {
$this->CI->load->model('pageTitle_model');
$title = $this->CI->pageTitle_model->getPagetitle($page_id);
return $title;
}
}