我做了一个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