-1
我正在創建一個博客的基本教程。在刪除步驟,我有:刪除帖子時自定義setFlash()
public function delete($id){
// if($this -> request -> is('get')){
// throw new MethodNotAllowedException(); }
if ($this -> Post -> delete($id)) {
$this -> Session -> setFlash(
__('The article %s was deleted', h($id)));//here is the line
return $this -> redirect(array('action' => 'index'));
}
}
我想的The article ID was deleted
而不是讓The article TITLE was deleted
;
我的問題是爲什麼下面的代碼在這種情況下不起作用?
__('The article %s was deleted', h($title)));
我曾經在任何地方見過h宣言?? – 2014-10-12 11:51:38
您如何期待這種工作,在您的代碼中沒有任何名稱爲'title'的變量? – ndm 2014-10-12 12:02:58
@AvinashBabu,沒有聲明。原文可以在這裏找到http://book.cakephp.org/2.0/en/getting-started.html#deleting-posts – ADDA 2014-10-12 12:11:20