PHP 检查 GET 参数是否在 .txt 文件中并且 return 响应 yes/no
PHP Check if GET parameter is in .txt file and return a response yes/no
我是 PHP 的新手,所以我想知道如何制作一个脚本,您必须放置一个 GET 参数 (index.php?test=value) 并检查是否为值在提供的 txt 文件中。如果该值存在则打印 yes 如果不存在则打印 no,如果没有 GET 参数打印如 ''empty''。请帮助我如何做到这一点。
$_GET['test'] = 'value';
if(empty($_GET['test'])) {
echo 'empty';
} else {
$file ='asdfasdfasvalue';
if(strpos($file, $_GET['test'])) {
echo 'yes';
} else {
echo 'no';
}
}
您应该使用文件内容填充 $file
。
正在使用的函数...
http://php.net/manual/en/function.empty.php
http://php.net/strpos
http://php.net/manual/en/function.file-get-contents.php
我是 PHP 的新手,所以我想知道如何制作一个脚本,您必须放置一个 GET 参数 (index.php?test=value) 并检查是否为值在提供的 txt 文件中。如果该值存在则打印 yes 如果不存在则打印 no,如果没有 GET 参数打印如 ''empty''。请帮助我如何做到这一点。
$_GET['test'] = 'value';
if(empty($_GET['test'])) {
echo 'empty';
} else {
$file ='asdfasdfasvalue';
if(strpos($file, $_GET['test'])) {
echo 'yes';
} else {
echo 'no';
}
}
您应该使用文件内容填充 $file
。
正在使用的函数...
http://php.net/manual/en/function.empty.php
http://php.net/strpos
http://php.net/manual/en/function.file-get-contents.php