Welcome Guest, Not a member yet? Register   Sign In
Trying to get started with your book "Codeigniter for Rapid PHP Application Development"
#1

[eluser]dallasray[/eluser]
I have created my first controller by following instructions in your book "Codeigniter for Rapid PHP Application Development". When I test it in my browser at http://localhost/index.php/start/hello/fred - I get an error in the browser that says

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: base
Filename: controllers/start.php
Line Number: 21
Fatal error: Cannot access empty property in /Applications/MAMP/htdocs/cipackt/system/application/controllers/start.php on line 21

I removed that line and get the same error for the variable css

Have I not declared them before the constructor?

-----------
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
* Description of start
*
* @author dallasray
*/
class Start extends Controller {
//put your code here

var $base;
var $css;

function Start()
{
parent::Controller();
$this->$base=$this->config->item('base_url');
$this->$css=$this->config->item('css');

}

function hello($name)
{
$data['css'] = $this->css;
$data['base'] = $this->base;
$data['mytitle'] = 'Welcome to Dallas Ray\'s Site';
$data['mytext'] = 'Now we are getting dynamic';
$this->load->view('testview',$data);
}

}
?>


Messages In This Thread
Trying to get started with your book "Codeigniter for Rapid PHP Application Development" - by El Forum - 12-01-2009, 05:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB