I have a class, which looks like this:
[FONT=Courier New]
<?php
class ClassName{
var $FileName = "";
var $Columns = 3;
var $HeadersOnOff = false;
var $Headers = "hello1,hello2,hello3";
/*
* Checks to see if the number of headers
* matches the number of columns.
* If not, the number of headers denotes
* the number of columns.
*/
function Headers_Match_Cols(){
echo $this->$Columns;
echo "<br />";
echo $this->$Headers;
}
}
?>
[/FONT]
And i call the class from another file using:
[FONT=Courier New]
<?php
include('class.php');
$oClass = new ClassName;
$oClass->$Columns = 3;
$oClass->$Headers = "1,2,3";
$oClass->Headers_Match_Cols();
?>
[/FONT]
However, the output I get is weird, depending on where I place the variable assignments in the main file (not the class). According to the above, this is what's returned (after assigning DIFFERENT values to both $Headers and $Columns, THEN running the 'Headers_Match_Cols()' function):
[FONT=Courier New]
1,2,3
1,2,3
[/FONT]
It seems it's just taking the first variable assigned, as opposed to 'echoing' out the correct variables, $this->$Headers, and $this->$Columns! Can anyone point out what i'm doing wrong? I'm sure it's something simple!
Ed.