PHP

PHP: Script Base Url

To get the url of current script’s directory:

$script_url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'];
$dir_url = preg_replace("/[^\/]*.php/", "", $script_url);

Variable Format
$_SERVER['SERVER_NAME'] localhost
$_SERVER['SCRIPT_NAME'] /internship/index.php
$script_url http://localhost/internship/index.php
$dir_url http://localhost/internship/
Standard