PHP Undefined Variable Error Newbie Here, Can't seem to figure out how to fix error
<p>I am trying to create a so-called Greek Numerals Converter tool. The input here will be letters and these letters will be converted into numbers. For every letter, there will be a corresponding number for it and also taking into consideration the digits. Now, my idea here is to create an array wherein all the letters and their corresponding numerical values will be put. So, when the user enters a combination of letters (up to 3 digits only), the convert() function will be looking for the corresponding values of those letters entered, get the values, and sum everything up. Unfortunately, as I went along the coding, I came up with this error (the one mentioned in the title) and I can't seem to figure out how to solve it. This might sound very stupid, but please do understand as I am still in the process of learning PHP.</p>

<p>Here are the codes that I was able to come up with.</p>

<pre><code>&lt;?php error_reporting(0);
    class GreekNum
    {


        public function setText($text)
        {
            $this-&gt;text=$text;
        }

        public function getText()
        {
            return $this-&gt;text;
        }       

        public function Convert($text)
        {

            $TextLength = strlen($text);
            $text = strtoupper($text);
            $text = str_split($text);



            $collection = array(
                                    "A" =&gt; 1,
                                    "B" =&gt; 2,
                                    "G" =&gt; 3,
                                    "D" =&gt; 4,
                                    "E" =&gt; 5,
                                    "#" =&gt; 6,
                                    "Z" =&gt; 7,
                                    "Y" =&gt; 8,
                                    "H" =&gt; 9,
                                    "I" =&gt; 10,
                                    "K" =&gt; 20,
                                    "L" =&gt; 30,
                                    "M" =&gt; 40,
                                    "N" =&gt; 50,
                                    "X" =&gt; 60,
                                    "O" =&gt; 70,
                                    "P" =&gt; 80,
                                    "Q" =&gt; 90,
                                    "R" =&gt; 100,
                                    "S" =&gt; 200,
                                    "T" =&gt; 300,
                                    "U" =&gt; 400,
                                    "F" =&gt; 500, 
                                    "C" =&gt; 600,             
                                    "$" =&gt; 700,
                                    "W" =&gt; 800,
                                    "3" =&gt; 900, 
                                );

            if(isset($text))
            {
                $total = 0;
                for($i=0; $i&lt;$TextLength; $i++)
                {
                    if(array_key_exists($text[$i], $collection))
                    {
                        $total += $collection[$text[$i]];
                    }

                    if(end($text)!='.')
                    {
                        echo "Please make sure your line ends with a period. &lt;br&gt;&lt;br&gt;"; 
                        return false;
                    }
                }
                return $total;

            }                   
        }

    }   

    $GreekNum = new GreekNum();

    $text = $_POST['text'];
    $GreekNum-&gt;setText($text);

    echo "&lt;br&gt;";
    echo "&lt;b&gt;Entered Values: &lt;/b&gt;&lt;br&gt;". $GreekNum-&gt;getText();
    echo "&lt;br&gt;";
    echo "&lt;br&gt;";

    echo "&lt;b&gt;Decimal Number Equivalence: &lt;/b&gt;&lt;br/&gt;". $GreekNum-&gt;Convert($text);




    ?&gt;
</code></pre>

<p>The error is about the $total and I can't seem to figure out how to fix this. Any help would be very much appreciated. Thanks a lot!</p>

<p>This has been resolved already, but for the sake of whoever might need this, I'm editing this again to the code that currently works for me.</p>
