如何防止包含的PHP脚本更改位置URL?

Rob*_*cks 2 php url redirect location

我包含一个更改URL的PHP​​脚本.

// index.php
ob_start();
include "script.php";
   // This script redirects using  header("Location:");
$out = ob_get_clean();
// I use the $out data for calculations
echo $out;
Run Code Online (Sandbox Code Playgroud)

有没有一种简单的方法来反击或撤消这种不需要的重定向?怎么样:

header("Location: index.php");   // redirect back to self
Run Code Online (Sandbox Code Playgroud)

但这导致无休止的重定向循环...任何想法?

或者有没有办法从$ out缓冲区中去掉header()调用,防止它到达客户端?

Ion*_*tan 5

仅供将来参考.从PHP 5.3开始,有一个名为header_remove()的新函数可以帮助处理这种情况.