简体   繁体   English

Haxe / PHP服务器更改输出而不编译文件

[英]Haxe / PHP server changing output without compiling file

I'm making a web app in Haxe and compiling it to PHP. 我正在Haxe中制作一个Web应用程序并将其编译为PHP。 I test the PHP code on my local server ( php -S ). 我在本地服务器( php -S )上测试PHP代码。

Here's the code: 这是代码:

    //...
    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
            }
    }

The server gives this error (no error when compiling): 服务器给出此错误(编译时无错误):

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}

And this is where the really weird part begins: When I change something in the code (it doesn't have to affect the app, even a comment would do), don't build it and reload the page, it suddenly works. 这就是真正怪异的部分开始的地方:当我更改代码中的某些内容(它不必影响应用程序,甚至注释也可以这样做), 不构建它并重新加载页面时,它突然起作用。 But when i build the code, it gives the error again. 但是当我构建代码时,它再次给出错误。

Is it some bug in the server or do I make a mistake somewhere? 服务器中是否有错误或在某处出错?


EDIT 编辑

I moved the testing server to Apache and the problem still persists. 我将测试服务器移至Apache,问题仍然存在。

I found out that the exists function from the StringMap class didn't get compiled to PHP for some reason, so i edited the code to be like this: 我发现了exists功能从StringMap类没有被编译到PHP由于某种原因,所以我编辑的代码是这样的:

//...
if (Session.get("username") != null && Session.get("password") != null) {

and it works now. 现在就可以了。 Don't know why the output changed when I didn't compile the file, but that doesn't matter. 不知道为什么当我不编译文件时输出会改变,但这没关系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM