Hello Readers ,
If you want to echo out the current URL in cakephp then follow the below codes.
Current URL: http://example.com/controller/action/?query=12
We can do it this way like.
<?php echo $this->request->here; ?>
By using this above one line code It will give you the prefect/complete url from the hostname i.e. /controller/action/params
Or if you want the full URL with host name you can use the code like this.
<?php echo Router::url( $this->here, true ); ?>
which will give you the full url with the hostname.
That's it.
Happy Coding
0 Comment(s)