在include中运行脚本的PHP错误

I have a script in PHP that gives me an error:

Trying to get property of non-object in /home/include/common.php line 20

this is file common.php

    function Template($name, $type = -1) {
    // todo: default $name from the script name withouth the extension?
    $this->path = Template::getPath($name, $type);// this is the line 20

    // todo: verify the existance of the file
    // and throw the fatal error if not available
}

I am not so good in PHP and I am not sure if there is some php module missing in my php conf or another problem, any help would be appreciated thanks

Is Template a class? If yes, should function Template($name, $type = -1) be the constructor?

Because if so, this isn't right for PHP.

In PHP you use (e.g.):

function __construct($name, $type = -1);

as a constructor.

Second, if you want to call a static method in the same class in PHP you do this by (e.g.):

self::getPath($name, $type);

I hope this solves your problem.

So you use self:: for static calls and $this-> for calls to the object.

If you need a Destruktor as well this would be __destruct (Methods with a __ in front are called "magic methods" and there are a lot of useful things you may want to look at ;-) ).