且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP验证的***实践...?

更新时间:2022-12-05 21:02:54

include_once require_once 绝对会保证你没有相同的文件包括超过一次(同时确保你身份验证)。

include_once and require_once will definitely assure that you don't have the same file included more than once (at the same time make sure you're authenticated).

我会做什么,但是,是添加包含在一个包括文件夹,禁止接入 - 谁的人将在路径手动输入 - 通过htaccess文件。通过这种方式,你可以让你的包含在一个地方(无论你的头包含可能看起来像),并保持你的头文件干净,仍遥不可及。如果你做到这一点你只要做一月在上面的答复中提到,检查如果你的 $ _ SESSION ['记录'] 设置(和任何其他检查你需要)

What I would do, however, is add your includes in a "include" folder and forbid access - to people who would type in the path manually - through an htaccess file. This way you could keep your includes in one place (whatever your header includes might look like) and keep your include files clean and still out of reach. If you were to do this you'd only have to do what Jan. mentioned in the answer above and check if your $_SESSION['logged'] is set (and whatever other checks you need)