I am using CakePHP and want to create a URL to a controller/view 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 the URL without the HTML around it.
echo $this->Html->url(array('controller' => 'bar', 'action' => 'display'));
With optional second parameter to make it a full URL including http://
and so on:
echo $this->Html->url(array('controller' => 'bar', 'action' => 'display'), true);
I just needed the same thing, but it changed on Cake 3. Now we have to use:
echo $this->Url->build(["controller" => "bar", "action" => "display","bar"]);
If you only need URL:
echo $this->Html->url(array('controller'=>'bar','action'=>'display'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With