PHP: exit 会不会有什么危害;在脚本的末尾?

PHP: will there be any possible harm if I put exit; at the end of the script?

显然,如果我将 exit; 放在 index.php 的末尾,对我的 CodeIgniter 应用程序的请求最多可以节省 300 毫秒

/*
 * --------------------------------------------------------------------
 * LOAD THE BOOTSTRAP FILE
 * --------------------------------------------------------------------
 *
 * And away we go...
 */
require_once BASEPATH.'core/CodeIgniter.php';

/* End of file index.php */
/* Location: ./index.php */

exit; // <~~ save me ~300ms request time, from ~900ms to ~600ms

我知道,这很奇怪,我想不出任何合理的解释。我正在寻找答案并尝试在隔离环境中重现该行为。但与此同时,如果有任何我不知道的明显原因,我想问...

我放exit会不会有什么危害;在 CodeIgniter 3.0 的 index.php 末尾?

您是否考虑过关闭 xdebug 扩展并重新测试? 如果我在 windows 机器上执行此操作 - 所有 php 脚本运行得更流畅和更快 -

我问这个是因为你的出口无论如何都是文件的结尾。 在你的观点中写下类似

的内容

<h3>Rendertime:<?php echo $this->benchmark->elapsed_time();?></h3>

并查看@退出和不退出的执行时间。 大多数时候它们是一样的。