PHP object/variable error
<p>Disclaimer: I'm new to object-oriented PHP and I'm generally terrible at the language.</p>

<p>So I've got a class called "Page" in a file (class_lib.php) and I've created this variable and written a while/for loop that processes it when its set:</p>

<pre><code>public $extra= "";
if (isset($this-&gt;extra)) {
echo "&lt;table id=\"tab\"&gt;";
while (list($counter) = each($this-&gt;$extra)) {
    for ($i=0;$i&lt;3;$i++) {
    echo "&lt;tr class=\"tl\"&gt;";
    echo "&lt;td&gt;$counter[$i]&lt;/td&gt;";
    echo "&lt;/tr&gt;";
    }
}
}
</code></pre>

<p>On one page, I need a table printed out. The data for this is in an array:</p>

<pre><code>$page-&gt;extra = array( array('Track no.', 'Track title', 'Track length'),
                      array('01', 'Value1', 'No1'),
                      array('02', 'Value2', 'No2'),
                      array('03', 'Value3', 'No3'),
                      array('04', 'Value4', 'No4'),
                      array('05', 'Value5', 'No5'),
                      array('06', 'Value6', 'No6'),
                      array('07', 'Value7', 'No7'),
                      array('08', 'Value8', 'No8'),
                      array('09', 'Value9', 'No9'),
                      array('10', 'Value10', 'No10'),
                      array('11', 'Value11', 'No11'),
                      array('12', 'Value12', 'No12')
                     );
</code></pre>

<p>The errors I'm getting are:</p>

<blockquote>
  <p>Notice: Undefined variable: extra in C:\wamp\www\test\class_lib.php on line 47</p>
</blockquote>

<p>...and:</p>

<blockquote>
  <p>Fatal error: Cannot access empty property in C:\wamp\www\test\class_lib.php on line 47</p>
</blockquote>

<p>Here's the full class_lib.php file if needed:
<a href="http://pastebin.com/7XRjDKVU" rel="nofollow">http://pastebin.com/7XRjDKVU</a></p>

<p>...and the index.php:
<a href="http://pastebin.com/yHBYpNxd" rel="nofollow">http://pastebin.com/yHBYpNxd</a></p>

<p>I hope I've given enough information there - I'd appreciate any help.</p>
