Uninitalized String Offset
<p>I have written a class in php that is supposed to intake a formula with unknown numbers (an example formula would be x+y) and replace those numbers (x &amp; y) with numbers inputted by the user (and passed to this class). My class looks like this:</p>

<pre><code>                        &lt;?php
        class formula
        {
            //declarations
                private $form="";
                private $variables="";
                private $values="";
            //end of declarations

            public function __construct($f, $vars, $vals)
            {
                $form=$f;
                $variables=$vars;
                $values=$vals;
            }

            public function getEquation()
            {
                //declarations
                $curChar="";
                $varCount=0;
                $charCount=0;
                $formulaChar=array();
                $i=0;
                $equation="";
                $size=strlen($this-&gt;form);  //number of characters in $form
                //end of declarations

                while($i&lt;$size)
                {
                    $curChar=substr($this-&gt;form, $i);
                    $formulaChar[$i]=$curChar;
                    $i++;
                }

                while($charCount&lt;$size)
                {
                    $varCount=0;
                    while($varCount&lt;strlen($variables))
                    {
                        if($formulaChar[$charCount]==$variables[$varCount])
                        {
                            $formulaChar[$charCount]=$values[$varCount];
                        }
                        $varCount++;
                    }
                    $charCount++;
                }

                $charCount=0;

                while($charCount&lt;count($formulaChar))
                {
                    $equation.=$formulaChar[$charCount];
                    $charCount++;
                }
                return $equation;
            }

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

<p>For testing purposes, I created a page that passed some dummy values to the class, and then wrote the results to the screen:</p>

<pre><code>        &lt;?php
        include("formula.php");
        $formula="x+y";
        $variables=array("x", "y");
        $values=array(1,2);

        $test=new formula($formula, $variables, $values);
        echo $test-&gt;getEquation();

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

<p>When I run it however, I get an error saying I have an uninitalized string offset on line 65 ($equation.=$formulaChar[$charCount];). What exactly does that mean, and how do I fix it? I am guessing that I did something incorrectly with the array, but I am not 100 percent sure. </p>
