[eluser]adamp1[/eluser]
Right I really need someone to give this a go becasue its driving me insane. I have a very very simple test setup, a library, a controller and a view. All I am trying to do is load the library in the controller, set a value and then display it in the view.
Now I have done lots of CI development but I for some reason can't get this to work. Am I missing something simple?
The Library
Code:
<?php
class MyClass
{
var $myval = 0;
function MyClass()
{
print "Value = " . $this->myval . ", Expecting 0<br/>";
}
}
?>
Controller
Code:
<?php
class Test extends Controller
{
function Test()
{
parent::Controller();
$this->load->library('myclass');
$this->myclass->myval++;
print "Value = " . $this->myclass->myval . ", Expecting 1<br/>";
}
function index()
{
$this->myclass->myval++;
print "Value = " . $this->myclass->myval . ", Expecting 2<br/>";
$this->load->view('test');
}
}
?>
View
Code:
<?php
$this->myclass->myval++;
print "Value = " . $this->myclass->myval . ", Expecting 3<br/>";
?>
Please could someone have a look, as said this is driving me insane, its so simple but it just doesn't work. The output I get for some reason is the following:
Quote:Value = 0, Expecting 0Value = 1, Expecting 1
Value = 2, Expecting 2
Value = 2, Expecting 3
As you can see from the output, first of why is the second output not on its own line??
Also why when we do the last inc in the view does it seem to loose count. Its like the myclass values don't persist across from the controller into the view.