我正在调用一个在结尾执行重定向的函数。我可以阻止我调用的函数以某种方式执行重定向吗?
function a() {
// here i would want to prevent the redirect. but i must call b always
b();
return 'a';
}
//function that i can't modify. It always redirects.
function b() {
header("Location: http://google.com", true, 200 );
}
$return = a();
echo $return;
// expected output: 'a' not a redirect to google
如果你问为什么,我不想修改函数b()
,因为它是一个库函数。
答案 0 :(得分:3)
调用库函数后,尝试使用
header_remove("Location")
http://php.net/manual/en/function.header-remove.php
希望标题不会发送......
答案 1 :(得分:0)
header_remove(设置标题后)?