Welcome Guest, Not a member yet? Register   Sign In
view methode didnt pass data to the view
#1

[eluser]thomas86[/eluser]
Hello,

i started wie CI today and at the moment i work throw the user guide. Now i want to set up a simple view.

Here is my code:
Code:
// url http://localhost/ci/index.php/thomas/bla
// application\controllers\thomas.php
function bla()
    {
        $data = array(
               'title' => 'My Title',
               'heading' => 'My Heading',
               'message' => 'My Message'
          );
        $this->load->view('thomasview', $data);
    }


// application\views\thomasview.php
<html>
<head>
<title><?php $title; ?></title>
</head>
<body>
    <h1>&lt;?php $heading; ?&gt;</h1>
    &lt;?php $message; ?&gt;
&lt;/body&gt;
&lt;/html&gt;

I only get a WSoD, whats wrong with the code?

cheers
Thomas
#2

[eluser]n0xie[/eluser]
Did you turn on error_reporting?

Except for the fact that you forgot your echo's, there is nothing wrong with the code.
Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;&lt;?php echo $title; ?&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    <h1>&lt;?php echo $heading; ?&gt;</h1>
    &lt;?php echo $message; ?&gt;
&lt;/body&gt;
&lt;/html&gt;




Theme © iAndrew 2016 - Forum software by © MyBB