Shades88
Shades88

Reputation: 8360

Access to undeclared static property php fatal error

I am getting this error: Access to undeclared static property: DBug::$errorMsg

Following is the code

class DBug
{
    private static $errorMsg = array(
        1 => 'inv-req',
        2 => 'inv-reqPrm',
        3 => 'no-set',
        4 => 'less-h',
        5 => 'less-w'
    );

    public static function showTinyErrMsg($errCode=0) 
    {
        if(SHOW_ERROR_MSG_IN_RESPONSE === TRUE) {
            if(array_key_exists($errCode, self::$errorMsg)) {
            echo "// ".self::$errMsg[$errCode].";\n" ;
            }
        }
    }
}

I call this function by DBug::showTinyErrMsg(1);. I get the above mentioned error. I am surely missing some OO rule, please help me with this.

P.s: The reason for this class having all static member is, that it's a long standing class with all static members, so I had to add this new method as static

Upvotes: 0

Views: 19378

Answers (1)

Mitya
Mitya

Reputation: 34566

The property is $errorMsg, but you're calling $errMsg.

Upvotes: 14

Related Questions