What to do if the value passed from flash to php is garbled?

藏色散人
Release: 2023-03-12 16:30:02
Original
2066 people have browsed it

Solution to the garbled value passed from flash to php: 1. View all Flash codes; 2. Add "header('Content-Type:text/html;charset=utf-8' at the beginning of PHP );" That's it.

What to do if the value passed from flash to php is garbled?

The operating environment of this article: Windows7 system, PHP7.1 version, Dell G3 computer

Specific problem description:

The communication between PHP and Flash is all garbled.

No more nonsense, let’s go directly to the code

The complete code of PHP is as follows:

<!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>
Copy after login

All codes of Flash As follows:

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);
}
Copy after login

There is a msg dynamic text box and bt button in flash

Solution:

Add ## at the beginning of PHP #

<?php
header(&#39;Content-Type:text/html;charset=utf-8&#39;);
?>
Copy after login
Just one line like this, where UTF-8 is the encoding, you can modify it according to the encoding of Flash

Recommended learning: "

PHP Video Tutorial"

The above is the detailed content of What to do if the value passed from flash to php is garbled?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!