How to get current URL on phtml files

Simple tip where you will get the code to “extract” current Magento url from a template file.

Here is the code.

You can use it on any phtml file.

$this->helper('core/url')->getCurrentUrl() 


Behind the scenes, this calls a helper method and retrieves the current url.

You can also use this on any file by changing it to this code:

Mage::helper('core/url')->getCurrentUrl()