Strange, static variables cannot be assigned values! Solution
Source: Internet
Author: User
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 strange, static variables cannot be assigned a value!
The procedure is as follows:
Class dbManage {
Public static $ siteInfo; // site information
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 ???
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?
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service