Note that there are some explanatory texts on larger screens.

plurals
  1. POController output
    text
    copied!<p>Today i am trying to understand coding principles with Code Igniter framework. Nevertheless, i faced with stupid problem.</p> <p>Here is my controller grades:</p> <pre><code>&lt;?php class Grades extends CI_Controller { public function view() { $data['todo_list'] = array('Clean House', 'Call Mom', 'Run Errands'); $data['title'] = "My Real Title"; $data['heading'] = "My Real Heading"; $this-&gt;load-&gt;view('pages/home', $data); } } ?&gt; </code></pre> <p>And here is mine home:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;?php echo $title;?&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;&lt;?php echo $heading;?&gt;&lt;/h1&gt; &lt;h3&gt;My Todo List&lt;/h3&gt; &lt;ul&gt; &lt;?php foreach ($todo_list as $item):?&gt; &lt;li&gt;&lt;?php echo $item;?&gt;&lt;/li&gt; &lt;?php endforeach;?&gt; &lt;/ul&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The output is: </p> <blockquote> <p>A PHP Error was encountered</p> <p>Severity: Warning</p> <p>Message: Invalid argument supplied for foreach()</p> <p>Filename: pages/home.php</p> <p>Line Number: 11</p> <hr> <p>Severity: Notice</p> <p>Message: Undefined variable: heading</p> <p>Filename: pages/home.php</p> <p>Line Number: 6</p> </blockquote> <p>May I have missed something? I would like to find out how to solve this problem.</p> <p>Routes.php</p> <pre><code>$route['grades'] = 'grades'; $route['(:any)'] = 'pages/view/$1'; $route['default_controller'] = 'pages/view'; $route['404_override'] = ''; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload