跨类参数

I have these 2 classes in 2 different files

class Foo {      
  public $type = int;    
  function __construct($out = 1) {        
    $this->type=$out;    
  }

  public function get() {    
    return $this->type;    
  }    
}

AND

class bar {    
  function __construct {    
    echo $foo->get();    
  }    
}

maybe a dumb question but how come this is not working? In the above index.php file I have

 $vFoo = new Foo(15);
 $vBar = new Bar();

I though that Bar will echo Foo's type..

There is no $foo variable anywhere in your code and if it was, it would be out of scope. A class is not an object, learn the basics.

Probably what you want is:

class bar {

  function __construct($foo) {

    echo $foo->get();

  }

}

and then in the index.php:

$vFoo = new Foo(15); $vBar = new Bar($vFoo);

But what you really need is not the solution - it's learning the basics. You don't seem to grasp what an object is and how it relates to a class (this is what your question implies; I am sure you believe otherwise).