Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
每当加载 PHP 页面时,我想调用一个外部 PHP 文件。即使用户刷新页面,这个外部 PHP 文件也应该只加载一次。我该怎么办?在调用此外部 PHP 文件之前,我可以设置用户必须等待多长时间的时间间隔吗?
您可以使用 require_once 和 session。
session_start(); if (!isset($_SESSION['executed'])) { require_once('your_file.php'); $_SESSION['executed'] = true; }
您可以在上次执行此外部文件时写入文件或更好地写入数据库。因此,每次调用此文件时,您都会比较上次调用它的时间,如果不是太长则退出