2015-03-13 112 views
0

有没有办法在不使用header()的情况下重定向到php中的另一个页面?我不能使用header(),因为我先输出一些东西到页面。我已经考虑使用JavaScript的window.location,但我在php中使用if语句,所以有没有办法在PHP中去使用header()的另一个页面?提前致谢。有没有办法在不使用header()的情况下重定向到php中的另一个页面?

+0

喜欢这个? http://stackoverflow.com/questions/14955526/php-delay-on-redirect – 2015-03-13 13:35:29

回答

2

我不能用头(),因为我是第一个输出一些东西到页面。

您不应该使用header()解雇。使用output buffering仍然可以使用header()

例如:

<?php 

ob_start(); //start the buffer 
echo "This is some output"; //Output data 
ob_clean(); //Erase the buffer content 
header('Location: http://google.com'); //Redirect user 
0

使用PHP?编号

你已经提到过使用JS和window.location。

唯一的其他选择是Meta refresh

<meta http-equiv="refresh" content="0; url=http://example.com/">

+0

你的意思就像我的评论? – 2015-03-13 13:38:40

+0

@JelledeFries不,不是。 – rjdown 2015-03-13 13:43:31

+0

是的,我很抱歉,我只阅读了这个问题的评论。但我们的意思是一样的,我只是没有说出来,我很抱歉。 – 2015-03-13 13:49:34

相关问题