Welcome Guest, Not a member yet? Register   Sign In
Php code won't work in views (solved)
#1

[eluser]Unknown[/eluser]
Hello, I'm new here and new to CI.

I tried following some basic tutorials. But those codes won't work for me.

First, I changed default_controller from 'welcome' to 'toppage'.

Code:
$route['default_controller'] = 'toppage';
$route['404_override'] = '';

I created toppage.php in controllers

Code:
<?php
class Toppage extends CI_Controller {

    function index()
    {
        $data['title'] = "My Real Title";
        $data['heading'] = "My Real Heading";
        
        $this->load->view('toppage_view', $data);
    }
}
?>

Then created toppage_view.php in folder 'views'

Code:
<html>
<head>
<title><?php echo $title;?></title>
</head>
<body>
    <h1>&lt;?php echo $heading;?&gt;</h1>
&lt;/body&gt;
&lt;/html&gt;

These code didn't work at all.
Here is the output.
v

[Image: http://img28.imageshack.us/img28/9020/catscim.jpg]

I really don't know why it won't work. T_T
Any help appriciated.
Thanks in Advance : )




Theme © iAndrew 2016 - Forum software by © MyBB