title: PHP getting "Undefined Variable and "Empty property" errors with code
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index">PHP: “Notice: Undefined variable”  and “Notice: Undefined index”</a>  </p>
  </blockquote>
  
  
  
  <p>I have reduced this error down to the smallest amount of code and it is so small, that I really feel stupid here.</p>
  
  <p>I have 2 files class1.php :</p>
  
  <pre><code>  1 &lt;?php
    2 class insertText{
    3         //properties
    4         protected $paragraph1='&lt;p&gt;this is a test paragraph&lt;/p&gt;';
    5         protected $bigHeader='&lt;h1&gt;header1&lt;/h&gt;';
    6         protected $textArray;
    7
    8         public function __construct () {
    9                 $this-&gt;$textArray = array($this-&gt;$bigHeader1, $this-&gt;$paragraph1);
   10         }
   11         public function getText(){
   12                 return $this-&gt;$textArray;
   13         }
   14 }
   15 ?&gt;
  </code></pre>
  
  <p>and test.php:</p>
  
  <pre><code>1 &lt;?php
  2 include './class1.php';
  3 echo "Begin\n";
  4
  5 $filler = new insertText();
  6 echo $filler-&gt;getText();
  7
  8 echo "end\n";
  9 ?&gt;
  </code></pre>
  
  <p>When I run: 
      $ php text.php</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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.</p>