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.
我有一个用户访问 url 时发生的操作。该操作涉及 MYSQL 数据库的大量插入更新,并且需要一分钟才能完成。我想知道即使用户切换到另一个页面,此操作是否会继续?我希望如此,因为 PHP 是服务器端。但我想对此有一个明确的解释。任何人?
不,Apache 和 PHP 的默认操作是在用户断开连接时终止脚本。这种终止可能在连接断开后的任何时候发生,因此您的脚本可能会运行数小时,或者可能会立即终止。通常,当脚本尝试执行任何输出时会发生终止。
如果您需要在用户断开连接的情况下保持脚本运行,那么您必须使用
ignore_user_abort(TRUE);