CakePHP - Create Link Unlink URLs

I am using CakePHP and want to create a controller / view URL without including the anchor tag.

In other words, if I use

$this->Html->link('foo',array('controller'=>'bar','action'=>'display'));

Then the output is a formatted link that can be displayed ... but I just want a non-HTML URL around it.

+5
source share
3 answers
echo $this->Html->url(array('controller' => 'bar', 'action' => 'display'));

With an optional second parameter to make it a full URL, including http://etc:

echo $this->Html->url(array('controller' => 'bar', 'action' => 'display'), true);
+12
source

I just needed the same thing, but it changed to Cake 3. Now we have to use:

echo $this->Url->build(["controller" => "bar", "action" => "display","bar"]);
+2
source

If you only need the url:

echo $this->Html->url(array('controller'=>'bar','action'=>'display'));
+1
source

All Articles