Interview Questions

How to Get current URL in CakePHP?

CakePHP Interview Questions and Answers


(Continued from previous question...)

How to Get current URL in CakePHP?

To get current url in cakephp use,
echo Router::url($this->here, true);
This will give full URL with hostname.If you want to get relative path instead of full URL,then use the following code:
echo $this->here;
This will produce absolute URL excluding hostname i.e. /controller/abc/xyz/

(Continued on next question...)

Other Interview Questions