0

I have upgraded from PHP 5.3 to PHP 5.4 now are my class broken and I do not understand it why.

I have build this class:

class _g
{
    public static $init;

    public static function init()
    {
        if ( self::$init == null ) 
        {
            self::$init->sysLang = ( isset( $_SESSION['SYSTEM_LANG'] ) ? $_SESSION['SYSTEM_LANG'] : 'dk' );
            self::$init->apiPath = CSS_API_PATH .'theme/'. API_THEME_PATH_GFX .'/gfx/';
        }

        return self::$init;
    }
}

And I get this error message:

Warning: Creating default object from empty value in /var/html/.....

And I really do not understand how I can fix this problem?

hakre
  • 193,403
  • 52
  • 435
  • 836
ParisNakitaKejser
  • 12,112
  • 9
  • 46
  • 66

1 Answers1

1

First of all you should read article about how to migrate to PHP 5.4.

You don't have any object instantiated in the init viariable. In PHP 5.3 it generates Strict Standards but in PHP 5.4 this is a Warning.

E_STRICT is not a part of E_ALL in PHP 5.3, but since PHP 5.4 it is.

You should follow those standards so you should change your code to have the following line in the if statement:

self::$init = new stdClass();
hakre
  • 193,403
  • 52
  • 435
  • 836
  • somthing are worng, need to search more on it when i came home, will it help if i reinstall the server to Debian 5.6? i think maby the PHP version and the newer MySQL make trobules.. :S – ParisNakitaKejser Feb 09 '15 at 10:06
  • Its working now! :) thanks a lot and i have a small mysql errors to ;) but its working now and thanks! :) – ParisNakitaKejser Feb 09 '15 at 14:06