Classes And Namespaces
First off you are trying to instantiate your class 'method'. This cannot be done. Instead, you instantiate your 'class' first then you call your 'method'.
http://php.net/manual/en/language.oop5.basic.php
Next, if you are not using an autoloader you must 'include' or 'require' the file containing the class you wish to use.
http://php.net/manual/en/function.include.php
http://php.net/manual/en/function.require.php
Instantiation & Method Calling
File Structure
+ Test.php (file)
+ NS (directory)
+ H.php (file)
File 'H.php'
<?php
namespace NS;
class H
{
public $v = 'now';
public static $v_ = 'static';
public function pm()
{
printf("<br/>public %s; variable v:%s", __METHOD__, $this->v);
}
public function getList()
{
printf("<br/> %s; Variable md5: %s", __METHOD__, md5($this->v));
}
public static function gl_()
{
printf("<br/> %s ; var: %s ; static: %s", __METHOD__, $this->v, self::$v_);
self::getList();
}
}
File 'Test.php'
<?php
// Include the file.
include 'NS\H.php'; // Delete if using an autoloader.
// Instantiate the object.
$o = new NS\H(); // Note: The 'NS\' (being your namespace and separator) after the 'new' keyword.
// The '()' are required after your class name.
// Call the objects method.
$o->getList();
?>
Namespaces
Secondly, regarding the namespace issue, there are multiple ways one can do this.
http://php.net/manual/en/language.namespaces.php
File 'Test.php' - Option 1 (As shown above)
<?php
// Include the file.
include 'NS\H.php'; // Delete if using an autoloader.
// Instantiate the object.
$o = new NS\H();
// Call the objects method.
$o->getList();
?>
File 'Test.php' - Option 2
<?php
// Include the file.
include 'NS\H.php'; // Delete if using an autoloader.
// Alias the class.
use NS\H;
// Instantiate the object.
$o = new H();
// Call the objects method.
$o->getList();
?>
File 'Test.php' - Option 3
<?php
// Include the file.
include 'NS\H.php'; // Delete if using an autoloader.
// Alias the class.
use NS\H as H; // Exactly the same outcome as option 2.
// Instantiate the object.
$o = new H();
// Call the objects method.
$o->getList();
?>
File 'Test.php' - Option 4
<?php
// Include the file.
include 'NS\H.php'; // Delete if using an autoloader.
// Alias the class.
use NS/H as Abc;
// Instantiate the object.
$o = new Abc();
// Call the objects method.
$o->getList();
?>
Autoloading (Extra Reading)
Lastly, all of the above is really wrapped up nicely when one uses an autoloader.
http://php.net/manual/en/language.oop5.autoload.php
Using an autoloader eliminates the need to write 'include' and 'require' throughout your code. Whilst there is nothing wrong with this (this is the way autoloaders actually work) it will improve development time and reduce errors.
I hope this helps.