我是新的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