1
votes

I'm running Ubuntu + PHP 5.4 and got such error:

Strict Standards: Non-static method XTemplate::I() should not be called statically, assuming $this from incompatible context in ... on line 339

And that method looks like this:

interface ITemplate
{
    public function I();
}

class XTemplate implements ITemplate
{
    public function I()
    {
             ...
    }
}

And this code is running normal on Windows 7 in XAMPP. I have found only advices to turn off error_reporing, but I need to solve it. Do I need to install some modules on turn on some other settings in php.ini ?

2
How do you call the function I()?1615903
I call it like that: XTemplate::I()->makeTemplate(...);Peter

2 Answers

4
votes

You are getting the error message because you are calling the function statically instead of creating an instance of XTemplate class. Depending on your situation, either make the function static:

static public function I()
    {
             ...
    }

Or first create an instance of XTemplate:

$myXtemplate = new XTemplate();
$myXtemplate->I();

I hope this answers your question.

Edit: This page may be interesting to you.

-1
votes

I had same error, all you need is a change in Interface: public function I(); change to public static function I(); and when you create instance use

public static function I();

I hope this help.