Help with PHP Error message?

Discussion in 'PHP' started by medialab, Mar 3, 2014.

  1. #1
    Hey Everyone,

    I am getting a weird error message all of the sudden on my page and I don't know why? Any help would be greatly appreciated!

    ERROR MESSAGE
    --------------------

    Strict Standards: Accessing static property Posts::$sessionholder as non static

    CODE ITS REFERENCING
    ----------------------------

    class Posts {

    public static $sessionholder;

    function __construct() {
    $this->sessionholder = $_SESSION;
    }

    -----------------------

    Any ideas what could be causing this?
     
    Solved! View solution.
    medialab, Mar 3, 2014 IP
  2. #2
    Hi,

    the class property $sessionholder is declared as 'static', which means it is associated with the class itself, rather than with the object you initialize by __construct. In this case, I believe you want to remove the keyword 'static' from the $sessionholder declaration (http://www.php.net/manual/en/language.oop5.static.php). It will suppress the error message.

    Also, if you didn't previously see this message, you should consider disabling display_errors directive - http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors
    or changing error_reporting level.
     
    Jiri Eichler, Mar 3, 2014 IP
  3. medialab

    medialab Well-Known Member

    Messages:
    366
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    138
    Digital Goods:
    1
    #3
    Hey Jiri,

    Great first post! Already a Best Answer and a Thank you! Worked like a charm!
     
    medialab, Mar 3, 2014 IP
  4. Jiri Eichler

    Jiri Eichler Greenhorn

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    2
    Trophy Points:
    11
    #4
    Thank you! I'm glad it helped.
     
    Jiri Eichler, Mar 4, 2014 IP