php的amf和flex通讯问题
这个例子中,为什么flex 调用的时候 不按顺序就出错,就是说PHP中的差别就是
require('D:/EmpireServer/ecshop/amfphp-2.1.1/Amfphp/Services/BaseAttribute.php');
语句出现的顺序。
edit_GetMaterialType_sq.php
<?php<br />class edit_GetMaterialType_sq<br />{<br />function IsLogin($isadmin)<br />{<br /> require('D:/EmpireServer/ecshop/amfphp-2.1.1/Amfphp/Services/BaseAttribute.php');<br /> $reLogin = array();<br /> $reLogin[] = 'IsLogin($isadmin)';<br /> return $reLogin;<br />}<br /><br />function get_materialtype()<br />{<br /> $g = array();<br /> $g[] = 'materialtype()' ;<br /> return $g;<br />}<br /><br />function get_templatetype($templateid,$userid)<br />{<br /> require('D:/EmpireServer/ecshop/amfphp-2.1.1/Amfphp/Services/BaseAttribute.php');<br /> $p = array();<br /> $p[] = 'get_templatetype' ;<br /> return $p ;<br />}<br />}<br />?>
BaseAttribute.php
<?php<br />class BaseAttribute<br />{<br /> var $Width = 0;<br /> var $Height = 0 ;<br />}<br />?>
在flex中这样调用测试的
example.mxml
<?xml version="1.0" encoding="utf-8"?><br /><s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"<br /> xmlns:s="library://ns.adobe.com/flex/spark"<br /> xmlns:halo="library://ns.adobe.com/flex/halo"<br /> xmlns:mx="library://ns.adobe.com/flex/mx"<br /> applicationComplete="application1_applicationCompleteHandler(event)"><br /> <br /> <fx:Script><br /><br /> <![CDATA[<br /> import mx.controls.Alert;<br /> import mx.events.FlexEvent;<br /> import mx.rpc.events.FaultEvent;<br /> import mx.rpc.events.ResultEvent;<br /> import mx.rpc.events.FaultEvent;<br /> import mx.rpc.remoting.RemoteObject; //RemoteObject,我认为相当于OLEDB的Connection,总的连接。<br /> <br /> <br /> <br /> protected function application1_applicationCompleteHandler(event:FlexEvent):void <br /> {<br /> // 在程序加载的时候运行该事件<br /> so.IsLogin(true) //注意这三行的顺序,不这样就出错<br /> so.get_materialtype() //注意这三行的顺序,不这样就出错<br /> so.get_templatetype(1,1) //注意这三行的顺序,不这样就出错<br /><br /> }<br /> public function RemoteFaultss(re:FaultEvent,title:String):void <br /> { <br /> Alert.show("Message:" +re.fault.content+":"+re.fault.faultDetail,title);<br /> }<br /> public function IsLoginRemoteResultss(re:ResultEvent):void<br /> { <br /> Alert.show( re.result.toString())<br /> <br /> }<br /> <br /> public function RemoteFault(re:FaultEvent,title:String):void <br /> { <br /> Alert.show("Message:" +re.fault.content+":"+re.fault.faultDetail,title);<br /> }<br /> public function IsLoginRemoteResult(re:ResultEvent):void<br /> { <br /> Alert.show( re.result.toString())<br /> <br /> }<br /> protected function button1_clickHandler(event:MouseEvent):void<br /> <br /> {<br /> <br /> // TODO Auto-generated method stub<br /> <br /> <br /> <br /> }<br /> <br /> public function RemoteFaults(re:FaultEvent,title:String):void <br /> { <br /> Alert.show("Message:" +re.fault.content+":"+re.fault.faultDetail,title);<br /> }<br /> public function IsLoginRemoteResults(re:ResultEvent):void<br /> { <br /> Alert.show( re.result.toString())<br /> <br /> }<br /> <br /> <br /><br /> ]]><br /> <br /> </fx:Script><br /> <br /> <fx:Declarations><br /> <s:RemoteObject id="so" destination="amfphp"<br /> source="edit_GetMaterialType_sq"><br /> <mx:method fault="{RemoteFaultss(event,'登录验证失败2')}" name="IsLogin"<br /> result="{IsLoginRemoteResultss(event)}"/><br /> <mx:method fault="{RemoteFault(event,'登录验证失败')}" name="get_materialtype"<br /> result="{IsLoginRemoteResult(event)}"/><br /> <mx:method fault="{RemoteFaults(event,'登录验证失败1')}" name="get_templatetype"<br /> result="{IsLoginRemoteResults(event)}"/><br /> <br /> </s:RemoteObject><br /> <br /> <!-- 将非可视元素(例如服务、值对象)放在此处 --><br /> <br /> </fx:Declarations><br /> <br /><br /><br /></s:Application>
------解决方案--------------------
你的 BaseAttribute.php 文件中是一个类定义
重复加载是会出错的!
require('D:/EmpireServer/ecshop/amfphp-2.1.1/Amfphp/Services/BaseAttribute.php');
应放在外面,不能放在方法里
------解决方案--------------------
方法里会起冲突

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver Mac version
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment
