Base URL in Cohan 3

How to get base URL in Kohana 3?

Is there a solution in raw PHP?

+4
source share
4 answers

In Cohan it is

echo url::base(); 

http://docs.kohanaphp.com/helpers/url


In source PHP

 echo "http://".$_SERVER['HTTP_HOST']."/NameOfApp"; 
+9
source

For Kohana 3, this is URL :: base () .

From the doc:

 // Absolute URL path with no host or protocol echo URL::base(); // Absolute URL path with host, https protocol and index.php if set echo URL::base('https', TRUE); // Absolute URL path with host and protocol from $request echo URL::base($request); 

Ref .: http://kohanaframework.org/3.1/guide/api/URL

+7
source

If you are worried about a lot of url::base() calls, you can turn it into a constant.

 define('PATH_BASE', url::base()); 
+4
source

I use this and it works.

 echo URL::base(); or echo URL::base(true); 
+2
source

Source: https://habr.com/ru/post/1300005/


All Articles