如何执行 flex 应用程序中另一个文件中的 php 代码?
我想执行的php代码(很好,很简单)
<?php
echo "My first PHP script!";
?>
所以我希望上述内容执行。到目前为止,我的 flex 应用程序中有这个:
<mx:HTTPService id="userRequest" url="C:UsersblahblahblahsrcItemTableService.php" useProxy="false" method="POST">
</mx:HTTPService>
</fx:Declarations>
<mx:Button label="Submit" click="userRequest"/>
所以我目前正在本地运行它。我认为"点击"用户请求需要有一些东西。(某事在这里)"/>但不确定它需要是什么。
我使用 UrlLoader 类
var url:String="example";
var urlRequest:URLRequest=new URLRequest(url);
urlRequest.method=URLRequestMethod.POST;
//use variables only if yu need them
var variables : URLVariables = new URLVariables();
variables.something=ex;
urlRequest.data=variables;
var urlLoader:URLLoader=new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, onComplete);
urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR,onError);
urlLoader.load(urlRequest);
首先尝试您的 php 和浏览器,看看您是否可以获得正确的 url,它应该是 localhost 或 127.0.0.1 之类的东西
http://localhost/myscript.php
按照 Josh 在评论中的建议进行编辑,您必须安装和设置 PHP 支持的 Web 服务器。