我正在尝试在我的 CodeIgniter 视图中打印我的键/值对数据。但是,我收到以下错误。我做错了什么?
遇到 PHP 错误
严重性:通知
消息:未定义变量:数据
文件名:views/search_page2.php
行号:8
应用程序/控制器/search.php
// ...
$this->load->library('/twitter/TwitterAPIExchange', $settings);
$url = 'https://api.twitter.com/1.1/followers/ids.json';
$getfield = '?username=johndoe';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$data['url'] = $url;
$data['getfield'] = $getfield;
$data['requestMethod'] = $requestMethod;
$this->load->view('search_page2', $data);
// ...
应用程序/视图/search_page2.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Twitter Test</title>
</head>
<body>
<?php print_r($data); ?>
<?php foreach ($data as $key => $value): ?>
<h2><?php echo $key . ' ' . $value . '<br />'; ?></h2>
<?php endforeach ?>
</body>
</html>