Strange things, static variables can not be assigned value! Solution Ideas

Source: Internet
Author: User
Strange things, static variables can not be assigned 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 is in the Scarlet Letter line. Obviously $_cookie["site" has data, but self:: $siteInfo is always empty. Would you please help me see what the reason is?

------Solution--------------------
How do You know self:: $siteInfo always empty???


------Solution--------------------
Self:: $siteInfo = $_cookie["Site"]; if (Empty (self:: $siteInfo) | | self:: $siteInfo ["domain"]! = $domain) {


You can use $_cookie["site" To assign a value, and then $siteinfo["domain" in a moment.

is $_cookie["Site" or $siteinfo an array? Where does domain come from?
------Solution--------------------
Self:: $siteInfo = $_cookie["Site"];//is this value an array?
if (self:: $siteInfo) | | self:: $siteInfo ["domain"]! = $domain)//You output a value within the condition to see if there is any execution, you know?

  • Related Article

    Contact Us

    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

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.