在这里,我将会话值传递给AS3,但我不想发送任何其他东西或页面内容,如HTML代码,另一方面,我不希望用户看到会话:x。将变量从PHP传递到AS3
<?php
session_start();
$session = $_SESSION['myusername'] ;
if(!isset($_SESSION['myusername'])){
header('location:../login.html');
} else{
echo "session:".$session;
header('location:speaking.html');
}
?>
<html>
<!-- some HTML code-->
</html>
更新:
var sesname:String;
var loader : URLLoader = new URLLoader();
var req:URLRequest = new URLRequest("http://localhost/speaking.php");
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(req);
loader.addEventListener(Event.COMPLETE, connectComplete);
function connectComplete(event:Event):void{
var session:String = event.target.data;
sesname= session;
trace(sesname);
nextFrame();
}
输出您的意思是PHP的*检索*数据,而不是通过* *从PHP? – ihsan
@ ihsan。当用户登录时,我需要他的用户名才能发送到AS3。只有他的用户名不是页面中的所有内容之前或之后的回声。我不知道是否有正确的AS3或不。 – Amir
是这个命令'var req:URLRequest = new URLRequest(“http://localhost/speaking.php”);'调用上面的php代码?要从url请求中检索数据,您必须只返回一个变量 - 值对字符串,例如。 '<?php echo“var1 = val1&var2 = val2”?>' – ihsan