Html markup in cakephp $ html-> link, e.g. $ Html-> link ('<SPAN> Hey </SPAN>')?

I have this code block in cakephp.ctp file:

<h1> <?php echo $this->Html->link('Hello <span>Stack Overflow</span>', array('controller'=>'pages', 'action'=>'home')); ?> </h1> 

But instead of html formatting, I see this literally:

 <h1><a href="/rrweb/www/hub/pages/home"> Hello &lt;span&gt;Stack Overflow&lt;/span&gt;</a></h1> 

Any idea?

Thanks!

+4
source share
2 answers

You need to disable the conversion of HTML objects :

 echo $this->Html->link( 'Hello <span>Stack Overflow</span>', array('controller'=>'pages', 'action'=>'home'), array('escape' => FALSE) ); 
+23
source

or

 echo $this->Html->link('Hello', array('controller'=>'pages', 'action'=>'home')).' '.$this->Html->tag('span', $this->Html->link('Stack Overflow', array('controller'=>'pages', 'action'=>'home')), array()); 
+1
source

All Articles