I’m just testing a little script for classes, having had a little problem with another i’m trying to figure it out using this.
here is my code:
<?
class testClass {
var $public_var;
function testClass() {
$this->$public_var = "theAssignedValue";
$this->test();
}
function test() {
echo(isset($this->$public_var)==true?"yes":"no");
echo($this->$public_var);
}
}
$myClass = new testClass();
?>
when i open that from my server, i get this output:
Notice: Undefined variable: public_var in C:\Program Files\Apache Group\Apache2\htdocs\class test.php on line 6
Notice: Undefined variable: public_var in C:\Program Files\Apache Group\Apache2\htdocs\class test.php on line 10
yes
Notice: Undefined variable: public_var in C:\Program Files\Apache Group\Apache2\htdocs\class test.php on line 11
theAssignedValue
If it works, why am i getting these errors ?
I am aware that changing the level of error that php warns for would help, but I would also like to know why it is an error in the first place.
Thank you for any insight you may provide.