Base Url Custom Function in PHP

i have created a custom function for printing the base url (url up to the current file from the server name).
here you can try .


public function base_url(){
$this->base_url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
return 'http://'.$this->base_url;



<a href="<?php echo 'base_url();' ?>"> this is base url </a>


(if your site running in server)

(if your site running in localhost)


2 thoughts on “Base Url Custom Function in PHP

  1. I read a lot of interesting posts here. Probably
    you spend a lot of time writing, i know how to save
    you a lot of time, there is an online tool that creates unique,
    SEO friendly articles in minutes, just search
    in google – laranitas free content source


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s