Encountered PHP transcoding problem, almost did not torture me, no matter what I call the project in those functions, white Kung Fu, may be off the wrong, do not know, to find a lot of online, finally, finally, I found:
Iconv ("UTF-8", "gb2312", $username);
And here's the question I'm having:
I'm going to use the session username, on the config.php page, I can get, assign to variable
$username =$_session[' user_name '];
$fromuser = $username;
Then you have to upload this value to another page and then save it to the database, which is a hassle from config.php to newmessage.php page,
<input type= "hidden" name= "Fromuser" id= "Fromuser" "value=" <?php echo $fromuser;?> "/>"
According to the above, the value to newmessage.php page will appear garbled. To say, my whole system is utf-8 coded, and
Config.php is gb2312 (I also do not know why the config.php code directly to the Utf-8 directly appear garbled, anyway, it is
gb2312 or GBK), so you need to turn the code, the username config.php directly into the gb2312, the cost of Dickens
Finally found this crazy code, my writing is this:
$fromuser =iconv ("UTF-8", "gb2312", $username);
Tencent's IP Address API interface address: http://fw.qq.com/ipaddress
The data format returned is: var ipdata = new Array ("114.218.183.139″," "," Jiangsu province "," Suzhou ");
Use JS code to make a fetch:
View Source code Printing Help
1 |
<script language= "JavaScript" Type= "Text/javascript" Src= "Http://fw.qq.com/ipaddress" ></script> |
3 |
<script>document.write ("Your IP is:" +ipdata[0]+ ", From:" +ipdata[2]);</script> |
Methods to parse using PHP:
View Source code Printing Help
02 |
function Getipplace () { |
03 |
$ip =file_get_contents ("http://fw.qq.com/ipaddress"); |
04 |
$ip =str_replace (' "', ' ', $IP); |
05 |
$ip 2=explode ("(", $IP); |
06 |
$a =substr ($ip 2[1],0,-2); |
07 |
$b =explode (",", $a); |
The output is an array after processing.
Other:
Sina's IP address query interface: HTTP://INT.DPOOL.SINA.COM.CN/IPLOOKUP/IPLOOKUP.PHP?FORMAT=JS
Sina Multi-Region test method: http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=218.192.3.42
Sohu IP Address Query interface (default GBK): Http://pv.sohu.com/cityjson
Sohu IP Address Query interface (can be set code): Http://pv.sohu.com/cityjson?ie=utf-8
Sohu additional IP Address query interface: HTTP://TXT.GO.SOHU.COM/IP/SOIP
This article links http://www.cxybl.com/html/wlbc/Php/20130113/36055.html