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起始處加上<?php header('Content-Type:text/html;charset=utf-8'); ?>
PHP視訊教學》
以上是flash傳值到php亂碼怎麼辦的詳細內容。更多資訊請關注PHP中文網其他相關文章!