Passing property to next method
<p>I have the following code within my class</p>

<pre><code>class Mail {
    function AddAttachment($path, $name = '', $filetype = 'application/octet-stream') {
        if (!@is_file($path)){
            echo'&lt;pre&gt;Filepath was not found.&lt;/pre&gt;';
        }

        if (empty($name)) {
            echo 'no filename';
        }

        //store attachment in array
        if(!isset($attachments)) {
            $attachments = array();
        }

        $attachments[] = array('path' =&gt; $path,'name' =&gt; $name,'type' =&gt; $filetype);
        //echo '&lt;pre&gt;';print_r($attachment);
        return  $attachments;
    }

    function SetMail() {
        foreach ($this-&gt;$attachments as $attachment) {
            echo '&lt;pre&gt;';print_r($attachment);
        }
    }
}

$mail = new Mail;
$mail-&gt;AddAttachment('../images/logo.png','filename');
$mail-&gt;AddAttachment('../images/logo.png','filensame');
$mail-&gt;SetMail();
</code></pre>

<p>As you can see, i fristly create the array's for the attachments (addAttachment), this works fine. Though I cannot seem to use this array in the next method.</p>

<p>I try'd to make the $attachments property public, but I still get these error messages:</p>

<p>(without public): Cannot access empty property</p>

<p>(with public): Cannot access empty property</p>

<p>(when using <code>self::$attachments</code> instead of <code>$this::$attachments</code>) :Access to undeclared static property: </p>

<p>Can anybody explain how i can pass the $attachments property to the SetMail method?</p>

<p>Thanks allready!</p>
