I am using XAMPP on Windows Vista. In my development, I have http://127.0.0.1/test_website/
.
How do I get http://127.0.0.1/test_website/
with PHP?
I tried something like these, but none of them worked.
echo dirname(__FILE__)
or
echo basename(__FILE__);
etc.
I think the
$_SERVER
superglobal has the information you're looking for. It might be something like this:You can see the relevant PHP documentation here.
you can do like this
but sorry my english is not good enough,
first get home base url with this simple code..
i've test this code by local server and public and result is good..
output will like this :
use home_base_url function at index.php of your website and define it
and then you can use this function to load script, css and content via url like
will create output like this :
and if this script works fine,,!
Function adjusted to execute without warnings:
Its just simple to use
Output :
Simple and easy trick:
URL looks like this:
http://example.com/folder/
The following code will reduce the problem to check the protocol. The $_SERVER['APP_URL'] will display the domain name with the protocol
$_SERVER['APP_URL'] will return protocol://domain ( eg:-http://localhost)
$_SERVER['REQUEST_URI'] for remaining parts of the url such as /directory/subdirectory/something/else
The output would be like this
http://localhost/directory/subdirectory/something/else