Passing variables between functions in PHP
<p>I'm slowly converting my work mode to functions and as well, OOP.</p>

<p>I have a file, <code>functions.php</code> which I call at the top of a log in page.</p>

<p>When the form on the page is submitted, I use a function within the functions file to check details entered are correct. If not I do e.g.</p>

<pre><code>if ($how_many&lt;1){

    $error .= "&lt;p&gt;You typed the wrong email address and/or password.&lt;/p&gt;";
    return $error;

}
</code></pre>

<p>I then have another function named <code>anyerrors</code> in the same functions file. This is:</p>

<pre><code>function anyerrors($error){
    echo $error;
}
</code></pre>

<p><strong>UPDATE:</strong> Then in the file I call <code>anyerrors($error);</code> where I want the error to be shown.</p>

<p>But nothing is being shown? I'm guessing it's because I'm creating the variable in one function and it's not getting to the other function.</p>

<p>Am I way off in my logic?</p>

<p>For the record I'm an old school coder I guess and taking time to change my work flow radically one step at a time.</p>
