Strange, static variables cannot be assigned values! The program is as follows: classdbManage {& nbsp; publicstatic $ siteInfo; Site Information & nbsp; ** & nbsp; * default execution & nbsp; * & nbsp; function _ construct () {& nbsp; $ do Strange, static variables cannot be assigned a value!
The procedure is as follows:
Class dbManage {
Public static $ siteInfo; // site information
/**
* Default execution
*/
Function _ construct (){
$ DomainKey = strtolower ($ _ SERVER ['server _ name']);
$ DomainKey = str_ireplace ("www.", "", $ domainKey );
Self: $ siteInfo = dbManage: getSiteInfo ($ domainKey );
}
Public static function getSiteInfo ($ domain ){
Self: $ siteInfo = $ _ COOKIE ["site"]; if (empty (self: $ siteInfo) | self: $ siteInfo ["domain"]! = $ Domain ){
$ SQL = "select * from site_config where domain = '{$ domain }'";
Self: $ siteInfo = self: queryArray ($ SQL );
Self: setCookie (self: $ siteInfo, "site ");
}
Return self: $ siteInfo;
}
}
The problem lies in the red line. Explicit $ _ COOKIE ["site"] contains data, but self: $ siteInfo is always empty. Which of the following experts can help me see why?
------ Solution --------------------
How do you know that self: $ siteInfo is always empty ???
------ Solution --------------------
Self: $ siteInfo = $ _ COOKIE ["site"]; if (empty (self: $ siteInfo) | self: $ siteInfo ["domain"]! = $ Domain ){
You will assign values using $ _ COOKIE ["site"] later, and use $ siteInfo ["domain"] later
Question: $ _ COOKIE ["site"] or $ siteInfo is an array? Where does domain come from?
------ Solution --------------------
Self: $ siteInfo = $ _ COOKIE ["site"]; // is this value an array?
If (empty (self: $ siteInfo) | self: $ siteInfo ["domain"]! = $ Domain) // You can output a value in the condition to see if there is any execution?