php - 用用户名和密码取消链接?

Ken*_*eth 0 php apache

我刚接触php.我有一个基本的unlink php文件删除test.html.使用Apache httpserver

<?php
$fh = fopen('test.html', 'a');
fwrite($fh, '<h1>Hello world!</h1>');
fclose($fh);

unlink('test.html');
?>
Run Code Online (Sandbox Code Playgroud)

那么现在我如何设置一个身份验证方法,以便只有具有正确用户名/密码的人才能访问此文件?

Amb*_*ber 6

如果您使用的是Apache,请查看htaccess密码.这可能是最简单的方法.