Welcome Guest, Not a member yet? Register   Sign In
Accessing controller public variables from multiple methods
#5

[eluser]chuckl[/eluser]
I just changed the code to create a new Test object and call the functions. I put the following code immediately after the closing brace of the Test class:

Code:
$test = new Test;
echo $test->index();
echo $test->test1();
echo $test->test2();

When I enter the URL ../index.php/test everything works as expected. You get the following output:

Code:
Class index() called.
This is a test of class public variable access.
Class test1 called.
This is a test of class public variable access.
This is a second test of the class public variable access.
The data array contains these two entries:
This is a test of class public variable access.
This is a second test of the class public variable access.
Class index() called.
This is a test of class public variable access.

When I enter the URL ../index.php/test/test1 I get the following output:

Code:
Class index() called.
This is a test of class public variable access.
Class test1 called.
This is a test of class public variable access.
This is a second test of the class public variable access.
The data array contains these two entries:
This is a test of class public variable access.
This is a second test of the class public variable access.
Class test1 called.
A PHP Error was encountered

Severity: Notice

Message: Undefined index: test1

Filename: controllers/test.php

Line Number: 26
This is a second test of the class public variable access.

When I enter the URL ../index.php/test/test2 I get the following output:
Code:
Class index() called.
This is a test of class public variable access.
Class test1 called.
This is a test of class public variable access.
This is a second test of the class public variable access.
The data array contains these two entries:
This is a test of class public variable access.
This is a second test of the class public variable access.
Class test1 called.
A PHP Error was encountered

Severity: Notice

Message: Undefined index: test1

Filename: controllers/test.php

Line Number: 26
This is a second test of the class public variable access.

What this tells me is that it isn't a PHP problem but a CodeIgniter issue since calling the class using PHP works fine but using the CodeIgniter URI to call the functions results in an error. I am open for ideas here. Thanks.


Messages In This Thread
Accessing controller public variables from multiple methods - by El Forum - 04-01-2011, 12:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB