我做了一個php腳本,看看txt文件的內容是否與用戶輸入相同。我寫了一個if語句來判斷它是否正確,以及它是否發送給其他人。如果我不發送任何變量,那麼它的工作原理,並顯示如果陳述不起作用,但有點工作
a is b is file is 1
,但如果我輸入文件和正確的內容,它顯示
a is test.txt b is hello file is hello 0
這裏是我的代碼
<?php
session_destroy();
$a=htmlspecialchars($_REQUEST['a']);
$b=htmlspecialchars($_REQUEST['b']);
$my_file = file_get_contents($a);
echo "a is $a\n";
echo "b is $b\n";
echo "file is $my_file\n";
if ($my_file == $b) {
echo "1";
}else {
echo "0";
}
?>
任何想法?
讀取輸入用裝飾有什麼文件中是否包含空格(空格,製表符,換行符等)? –
試試條件(trim($ my_file)== $ b) – janenz00
非常感謝!!!!!!我試過(修剪($ my_file)== $ b),它很完美 – user1685192