Tuesday, April 30, 2013

CakePHP get host name


cakephp - get the hostname and document root via env()

The env() function gets the environmental variables and as such we can get the http_host and document_root with its help.
eg env('HTTP_HOST') or env('DOCUMENT_ROOT').

It is advisable to use env() function instead of directly using $_SERVER etc.

No comments:

Post a Comment