您好,欢迎访问一九零五行业门户网

flash传值到php乱码怎么办

flash传值到php乱码的解决办法:1、查看flash全部代码;2、在php起始处加上“header('content-type:text/html;charset=utf-8');”即可。
本文操作环境:windows7系统、php7.1版,dell g3电脑
具体问题描述:
php和flash通信全是乱码的问题
废话不多说了,直接上代码
php全部代码如下:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>test</title></head><body><?php$sending="这是返回的数据";echo "$sending";?></body></html>
flash全部代码如下:
import flash.events.mouseevent;import flash.net.urlrequest;import flash.net.urlloader;import flash.events.event;var url:string = "http://localhost/testing.php";var req:urlrequest=new urlrequest();bt.addeventlistener(mouseevent.click,clickhd);function clickhd(e:mouseevent){req.url = url;req.method = urlrequestmethod.post;var loaded:urlloader=new urlloader();loaded.dataformat = urlloaderdataformat.variables;loaded.addeventlistener(event.complete,completehd);try{msg.text = "正在请求数据。。。";}catch (err:error){msg.text = "错误,稍后再试";}loaded.load(req);}function completehd(e:event){msg.text = e.target.data;navigatetourl(req);}
flash中有个msg动态文本框和bt按钮
解决办法:
在php起始处加上
<?phpheader('content-type:text/html;charset=utf-8');?>
这么一行就行,其中utf-8是编码,你根据flash的编码进行修改
推荐学习:《php视频教程》
以上就是flash传值到php乱码怎么办的详细内容。
其它类似信息

推荐信息