Possible Duplicate:
PHP: “Notice: Undefined variable” and “Notice: Undefined index”
I have reduced this error down to the smallest amount of code and it is so small, that I really feel stupid here.
I have 2 files class1.php :
1 <?php
2 class insertText{
3 //properties
4 protected $paragraph1='<p>this is a test paragraph</p>';
5 protected $bigHeader='<h1>header1</h>';
6 protected $textArray;
7
8 public function __construct () {
9 $this->$textArray = array($this->$bigHeader1, $this->$paragraph1);
10 }
11 public function getText(){
12 return $this->$textArray;
13 }
14 }
15 ?>
and test.php:
1 <?php
2 include './class1.php';
3 echo "Begin\n";
4
5 $filler = new insertText();
6 echo $filler->getText();
7
8 echo "end\n";
9 ?>
When I run: $ php text.php
Begin
PHP Notice: Undefined variable: bigHeader1 in class1.php on line 9
PHP Fatal error: Cannot access empty property in class1.php on line 9
I know that this has te be an easy answer, and I did search and search every post with either error message. I even tried moving the assignment of text to the variables to within the constructor and it dodn't work.