This article mainly introduces the difference between the Key quotation marks and the no quotation marks of the php array index. there is a serious difference between the quotation marks and the no quotation marks, you can refer to the following sentence when reading a PHP blog today: "If the index KEY value in PHP is not enclosed in quotation marks, the index KEY value is interpreted as a constant. if the definition of the constant cannot be found, it is interpreted as a string ". I am a bit unconvinced, because I always enclose the index KEY in quotation marks, so this is not the case. Take the time to write a line of code and test it:
The code is as follows:
Define ('webhost', 'blog ');
$ Wso = array ();
$ Wso ['blog '] = 'www .weixiaodeyu.com ';
$ Wso ['webhost'] = 'www .bitsCN.com ';
Echo $ wso [WEBHOST]; // output www.weixiaodeyu.com
Indeed, the output is www.weixiaodeyu.com instead of www.bitsCN.com. Now we know the importance of adding quotation marks to the index KEY value. If an unexpected error occurs, check it. In fact, strict execution of language specifications will not result in this difficult debugging error.