Recently on the SAE to write microblogging applications, encountered some minor problems, write down, for reference:
1. Error prompt:
Fatal Error:can ' t use function return value in write context
The reason for the problem is very simple, $_get, $_post, such as the predefined variable is an array is not a function, if you use $_get ("paramname") such a method to get the parameter will encounter this error, the correct practice is to use square brackets: $_get[' paramname '].
2. How to transfer Chinese between Ajax and PHP programs:
2.1, Ajax to submit Chinese data to the PHP program, my Web page using UTF-8 encoding, request to submit before I use the jquery serialization function to the request parameters have been processed (before this aspect of processing is to request the parameter string to do two encodeURI processing, This function of jquery greatly simplified this work):
var paramdata=$ (' #formID '). Serialize ();
After the request is submitted, the UrlDecode function is used to do one processing to get the correct UTF-8 Chinese code:
$paramValue=urldecode($_get["paramname"]);
If the page is GBK encoded, it seems like to use the Iconv function to do one more step.
2.2, the PHP program to the Ajax script to return to the Chinese language is more simple, add a set encoding the header can be: because I use the UTF-8 code, so add the following:
Header (' Content-type:text/html;charset=utf-8 ');
Some minor problems with PHP coding