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?

2
  • what kind of type is _g::$init, can you provide full error? Commented Feb 9, 2015 at 7:35
  • the provide error its what i type, i don't get eny orther error. and type? its a static var / object. Commented Feb 9, 2015 at 7:42

1 Answer 1

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();
Sign up to request clarification or add additional context in comments.

2 Comments

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
Its working now! :) thanks a lot and i have a small mysql errors to ;) but its working now and thanks! :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.