title: Getting calculated value from one function inside another function
body: <p>I have faced a little problem I can't seem to figure out. 
  I have a calculation class that calculates som quantities from various values and the I need those calculated values inside another function that will output a list with quantities, prices etc. </p>
  
  <p>But I can't get the values. I just get:</p>
  
  <pre><code>Fatal error: Using $this when not in object context in 
  </code></pre>
  
  <p>The function that prints the list is inside a class called Matliste</p>
  
  <pre><code>function PrintList($rid, $fields_to_select = array()) {
          $matliste = new Matliste;
          $matliste-&gt;GetCalculation($_GET["house"]);
  
          $types = join(",", $fields_to_select);
  
          $sql = "SELECT * FROM nt_stentyper INNER JOIN nt_tunliste ON nt_stentyper.varenr_tilb = nt_tunliste.varenummer INNER JOIN nt_priser ON nt_stentyper.varenr_tilb = nt_priser.varenummer WHERE nt_stentyper.tagsten = $rid AND nt_stentyper.prod_type IN ($types) ORDER BY nt_stentyper.prod_type ASC";
          $result = mysql_query($sql);
  
          $markers = array();
  
          $markers["###TABLEROWS###"] = "";
  
          $prodTypes = array("1" =&gt; $this-&gt;roofTiles, "2" =&gt; $this-&gt;roofBinders);
  
          while($row = mysql_fetch_array($result)) {
  
              $markers["###TABLEROWS###"] .= '&lt;tr&gt;';
              $markers["###TABLEROWS###"] .= "&lt;td&gt;". $row["varenummer"] ."&lt;/td&gt;";
              $markers["###TABLEROWS###"] .= "&lt;td&gt;". $row["tunnummer"] ."&lt;/td&gt;";
              $markers["###TABLEROWS###"] .= "&lt;td&gt;". $row["beskrivelse"] ."&lt;/td&gt;";
              $markers["###TABLEROWS###"] .= "&lt;td&gt;". $prodTypes[$row["prod_type"]] ."&lt;/td&gt;";
              $markers["###TABLEROWS###"] .= "&lt;td&gt;stk&lt;/td&gt;";
              $markers["###TABLEROWS###"] .= "&lt;td&gt;". str_replace(".", ",", $row["pris_dk"]) ." kr.&lt;/td&gt;";
          } 
  
          $finalPrice = mysql_fetch_array(mysql_query("SELECT *, SUM(pris_dk) AS pris FROM nt_stentyper INNER JOIN nt_tunliste ON nt_stentyper.varenr_tilb = nt_tunliste.varenummer INNER JOIN nt_priser ON nt_stentyper.varenr_tilb = nt_priser.varenummer WHERE nt_stentyper.tagsten = $rid AND nt_stentyper.prod_type IN ($types)"));
          $markers["###FINALPRICE###"] =  str_replace(".", ",", $finalPrice["pris"]);
          $markers["###LIST_FOR###"] = ($finalPrice["prod_type"] == 1) ? $finalPrice["beskrivelse"] : "";
          $markers["###PERCENTAGE###"] = $_GET["spild"];
          Main::GetMarkers($markers);
      }
  </code></pre>
  
  <p>$this->roofTiles and $this->roofBinders gives me the fatal error mentioned above.</p>
  
  <p>$this->roofTiles is calculated in the function in the Calculation class and is like this:</p>
  
  <pre><code>$this-&gt;Rooftiles = ceil((($areal_tagflade*$forbrug-$antaldblvinge*$daekbredde_dv_venstre_2-$antal_topsten-2))*$perc / 2) * 2;
  </code></pre>
  
  <p>but in the PrintList function I cannot get that value.</p>
  
  <p>$matliste->GetCalculation is this:</p>
  
  <pre><code>function GetCalculation($house) {          
  
          $calculations = new HouseCalculations;
  
          switch($house) {
              case 1:
                  $calculations-&gt;calc_normal($_GET["rid"], $_GET["rooftiletype"], $_GET["afslutning_sten"], (isset($_GET["wa"])) ? $_GET["wa"] : 0, (isset($_GET["kviste_1"])), (isset($_GET["kviste_2"])));                      
                break;
          }
      }
  </code></pre>