Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将变量传递给视图,使其成为数组的变量_Php_Codeigniter - Fatal编程技术网

Php 将变量传递给视图,使其成为数组的变量

Php 将变量传递给视图,使其成为数组的变量,php,codeigniter,Php,Codeigniter,我在codeigniter中创建了一个控制器,并在其中创建了两个阵列: $header_data['base_url'] = base_url(); $templates['header'] = "/application/views/templates/header.php"; $templates['auth_page'] = "/application/views/templates/auth_page.php"; $templates['footer'] = "/app

我在codeigniter中创建了一个控制器,并在其中创建了两个阵列:

  $header_data['base_url'] = base_url();

  $templates['header'] = "/application/views/templates/header.php";
  $templates['auth_page'] = "/application/views/templates/auth_page.php";
  $templates['footer'] = "/application/views/templates/footer.php";
现在,我创建了一个唯一的数组,其中包含以前的数组:

$page_data['data_header'] = $header_data;
$page_data['templates'] = $templates;
并将其传递给查看:

$this->load->view('main.php',$page_data);
现在,我们进入视图后,如何调用变量$base\u url,因为它位于
header\u data
中,它位于
$page\u data
数组中?

在视图中,您可以使用:


$page\u data['data\u header']['base\u url']
extract($data_header);

echo $base_url;