#在CakePHP $ this-> Html->链接中

Cam*_*003 1 php cakephp

我想知道如何在没有被转义的情况下向cakephp网址添加"#".我试过'逃'=>假但没有成功.我这样做是为了尝试链接到包含注释的页面的id ="comments"部分.这是我的链接代码:

<?php echo $this->Html->link($post['Post']['total_comments'].' comments', array('controller' => 'posts', 'action' => 'view', $post['Post']['slug'].'#comments'),array('class' => 'comments-icon')); ?>
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.

Aur*_*kus 6

试试这个:

echo $this->Html->link($post['Post']['total_comments'].' comments', array(
       'controller' => 'posts', 
       'action' => 'view', 
       $post['Post']['slug'], 
       '#' => 'comments' //Or #comments only without key
      ), array('class' => 'comments-icon'));
Run Code Online (Sandbox Code Playgroud)