0

这是我的代码:

        if(is_file($userName.".txt")) {
            $userDetails = explode(',', file_get_contents($userName.".txt"));
            print($userDetails[0]);
            if ($password == $userDetails[0]) {
                print('Correct login');
            } else {
                print('Incorrect login');
            }
        }

而且我有以下文件: Simon.txt 具有以下内容: simonpassword,4,1 如果 $userName 是“Simon”,则在运行代码时,为什么会打印出 4 而不是 simonpassword 在该行: print( $userDetails[0])?

4

1 回答 1

0
<?
$userName = "Simon";
$password = "simonpassword";
if(is_file($userName.".txt")) {
        $userDetails = explode(',', file_get_contents($userName.".txt"));
        print($userDetails[0]);
        if ($password == $userDetails[0]) {
            print('Correct login');
        } else {
            print('Incorrect login');
        }
    }
?>

这是西蒙.txt

simonpassword,4,1

它有效。

于 2012-05-17T11:29:29.093 回答