title: Call variable from a function that's inside a class?
body: <p>I just created my first PHP <code>class</code>, but I'm very new to this and now I don't know how to call a <code>variable</code> inside a <code>function</code> that I created.</p>
  
  <p>For example:</p>
  
  <pre><code>class Example
  {
    public function testFunction() {
      $var1 = "Test";
      $var2 = "Hello";
    }
  }
  </code></pre>
  
  <p>And then, for example, <code>echo</code> $var1.</p>
  
  <p>I know that I can call the function through this:</p>
  
  <pre><code>$something = new Example();
  $something-&gt;testFunction();
  </code></pre>
  
  <p>But how can I call one of those variables inside the function?</p>
  
  <p>I also know that if the variable was outside the function, it would be:</p>
  
  <pre><code>$something = new Example();
  echo $something-&gt;var1;
  </code></pre>
  
  <p>I could use a <code>return</code>, but that way I would end with just one variable, and I have multiple variables inside that function.</p>
  
  <p>I hope that you can help me.</p>