[英]Haxe / PHP server changing output without compiling file
我正在Haxe中制作一个Web应用程序并将其编译为PHP。 我在本地服务器( php -S
)上测试PHP代码。
这是代码:
//...
switch(page) {
//...
case "user":
//if logged in, display profile; if not, redirect to login
var loggedIn = false;
//check if user is logged in
if (Session.exists("username") && Session.exists("password")) {
var username:String = Session.get("username");
var password:String = Session.get("password");
//check the password
var conn = Mysql.connect({user: "..." pass: "...", host: "127.0.0.1", database: "..."});
var dbpass = conn.request("SELECT password FROM users WHERE username = \'" + username + "\';").results().first().password;
if (password == dbpass)
loggedIn = true;
}
if (!loggedIn) {
returnPage += File.getContent("../html/login.html");
} else {
//TODO add profile page
}
}
服务器给出此错误(编译时无错误):
uncaught exception: Unable to call <exists>
in file: /.../lib/haxe/ds/StringMap.class.php line 31
#0 /.../lib/Open.class.php(9): haxe_ds_StringMap->__call('exists', Array)
#1 /.../open/index.php(11): Open::main()
#2 {main}
这就是真正怪异的部分开始的地方:当我更改代码中的某些内容(它不必影响应用程序,甚至注释也可以这样做), 不构建它并重新加载页面时,它突然起作用。 但是当我构建代码时,它再次给出错误。
服务器中是否有错误或在某处出错?
我将测试服务器移至Apache,问题仍然存在。
我发现了exists
功能从StringMap
类没有被编译到PHP由于某种原因,所以我编辑的代码是这样的:
//...
if (Session.get("username") != null && Session.get("password") != null) {
现在就可以了。 不知道为什么当我不编译文件时输出会改变,但这没关系。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.