Can't call function of another class using OOP
<p>I'm a bit rusty with php, I want to know how I can call the function <code>login</code> available in <code>class2</code>, inside <code>class1</code>. This is the example:</p>

<pre><code>&lt;?php

    require_once("property2.php");

class Class1 
{
      public function __construct()
      {
         $cls2 = new Class2()
      }

      public function method1()
      {
          $cls2-&gt;login() //cl2 is undefined 
      }

} ..

//this is the function

...
class Class2
{
     public function __construct()
     {

     }

     //This is the  function to call

     public function login()
     {
       //Some stuff
     }
} ...
</code></pre>

<p>Now <code>PHPSTORM</code> say that the variable <code>cls2</code> is undefined. What I did wrong?</p>