Heim  >  Artikel  >  Backend-Entwicklung  >  $_POST[''];怎么用

$_POST[''];怎么用

WBOY
WBOYOriginal
2016-06-23 13:22:222292Durchsuche

我在flash里定义了message交给了post,然后phph里写$_POST['message'];想通过这样和actionscript交互,但是php编译通不过,错误信息是message没有定义。


回复讨论(解决方案)

那你看看都传了什么过来呀

把你代码贴出来

那你看看都传了什么过来呀


大版主大人
你接触过actionscript吗,这是我在网上找的actionscript代码,这个代码我也看不明白啊,这里面message应该是URLVariables的一个成员吧。而且它是属于对象values的,如果在php里直接写$_POST['message'];php怎么知道这个message是什么啊
 var loader:URLLoader = new URLLoader();//声明一个URLRequestvar url:URLRequest = new URLRequest("test.php");//设置传输方式为POSTurl.method = URLRequestMethod.POST;//声明一个URLVariablesvar values:URLVariables = new URLVariables();//设置要传输的信息values.message="hello im flash!";    url.data = values;loader.addEventListener(Event.COMPLETE,loaded); function loaded(e:Event){ trace(loader.data);   }loader.load(url);

把你代码贴出来


actionscript代码是这样
var loader:URLLoader = new URLLoader();//声明一个URLRequestvar url:URLRequest = new URLRequest("helloPhp.php");//设置传输方式为POSTurl.method = URLRequestMethod.POST;//声明一个URLVariablesvar values:URLVariables = new URLVariables();//设置要传输的信息values.message = "hello im flash!";url.data = values;//监听数据加载完成事件loader.addEventListener(Event.COMPLETE,loaded);function loaded(e:Event){	//在flash输出栏里输出php传来的数据	trace(loader.data);	}loader.load(url);


php是这样
<?php$data = 'hello im php~';echo $data;echo $_POST['message'];?>

预期效果是flash输出栏里显示“hello im php~"
php显示”hello im php~hello im flash!“

实际效果是php第四行编译通不过,说message没定义。
如果注释掉第四行则php显示”hello im php~“
flash输出栏把整个php文件的文本内容全部显示出来了,而不是显示”hello im php~“

把整个php文件的文本内容全部显示出来了
这是什么意思?

把整个php文件的文本内容全部显示出来了
这是什么意思?


这个样子:

你的 flash 不是从网站上加载的?

var url:URLRequest = new URLRequest("helloPhp.php");
应为
var url:URLRequest = new URLRequest("http://localhost/helloPhp.php");

你的 flash 不是从网站上加载的?

var url:URLRequest = new URLRequest("helloPhp.php");
应为
var url:URLRequest = new URLRequest("http://localhost/helloPhp.php");


原来是这样,php给actionscript传值弄好了,可是as传给php的message怎么弄啊。

echo $_POST['message'];
不行吗?

那这样呢
echo file_gey_contents('php://input');


你的 flash 不是从网站上加载的?

var url:URLRequest = new URLRequest("helloPhp.php");
应为
var url:URLRequest = new URLRequest("http://localhost/helloPhp.php");


原来是这样,php给actionscript传值弄好了,可是as传给php的message怎么弄啊。
它说file_gey_contents()函数没有定义。flash接收的是echo输出的数据,可是如果要动态地获取php里的不同数据,如何刷新echo的输出呢

file_ge t_contents

echo $_POST['message'];
不行吗?

那这样呢
echo file_gey_contents('php://input');


10楼引用错了,没at到你,我在fla里测试echo $_POST['message'];调用成功了,但是如果发布成swf就死活弄不好,用apache编译php也通不过。算了fla里能用就行了。非常感谢!终于弄好了!
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn