有人問這個quesion但沒有回答解決了這個問題頭時使用CakePHP
標題( 「刷新:5; URL = 'pagetoredirect.php'」);
我們可以利用這一點,如果我們想重定向我們的頁面以5秒,
,有沒有辦法在CakePHP的五秒重定向頁面?
如果是,請讓我知道
我想這代碼,但不能正常工作 /app/controllers/examples_controller.php
?php
class ExamplesController extends AppController
{
public $name = "Examples";
...
public function someAction(){
...
$url = array('controller' => 'examples', 'action' => 'someOtherAction');
$this->set('url', $url);
$this->header("refresh:5; url='".Router::url($url)."'");
}
...
}
?>
/app/views/examples/some_action.ctp
<p class='notice'>
<?php echo $this->Html->link("You are being redirected to ".Router::url($url)." in 5 seconds. If you do not wish to wait click here.", $url); ?>
</p>
這應該做到這一點,雖然沒有報價周圍的網址。 「不起作用」是什麼意思?你有錯誤嗎?標題沒有設置? – JJJ
發送此錯誤通知(8):未定義變量:url [APP \ views \ books \ add.ctp,第13行] – fakhrawy
@fakhrawy我已經嘗試了相同的http://stackoverflow.com/a/7260191/4380588,並且這個爲我工作。 –