0
votes

I have this function:

<?PHP
function T($w) {
    $method = $GLOBALS['G_SP']["lang"][spController::getLang()]; // LINE 2
    if(!isset($method) || 'default' == $method){
        return $w;
    }elseif( function_exists($method) ){
        return ( $tmp = call_user_func($method, $w) ) ? $tmp : $w;
    }elseif( is_array($method) ){
        return ( $tmp = spClass($method[0])->{$method[1]}($w) ) ? $tmp : $w;
    }elseif( file_exists($method) ){
        $dict = require($method);
        return isset($dict[$w]) ? $dict[$w] : $w;
    }else{
        return $w;
    }
}
?>

no i see this error in line 2:

Strict Standards: Non-static method spController::getLang() should not be called statically in C:\xampp\htdocs\inc\spFunctions.php on line 2

how to fix this error?

NOTE : i need to fix this without change php.ini (disable error_reporting = E_ALL | E_STRICT OR display_errors = On to Off)

2
have you verified that you are calling the method properly? from the error it seems that you should have an instance of spController and call getLang() from it instead of calling it as static.Pawel J. Wal

2 Answers

2
votes

If the spController::getLang() function is not referencing an instance property (using $this) then all you need is to add static to your function declaration. i.e

public static function getLang();

or if you are using a reference to $this you will need to create an instance of the pController and then call the getLang() method as a instance method.

$controller = new spController();
$lang = $controller->getLang();
0
votes
$sp = new spController();
$sp->getLang();

Or maybe an instance of spController already exists from somhere in your application