Feedback Form
Leads to Insight

Blog

Truck and Plow

22
Jun
2011


A PHP/MySql based Trucks, Plow and other automobile parts selling ecommerce website.

Truckandplow.com is the answer to all your truck automobile and plow accessories and parts requirements.

Technology Used:

PHP, MySQL, PayPal, Authorize.Net, UPS and USPS integration

Mercury Adult Care

1
Jun
2010

An Affordable Alternative to Home Health Care, Nursing homes or Assisted Living Facilities.

YellFX

12
Apr
2010

A PHP/MySql based corporate website with Australian Property Information and Zip Info Database.

Technology Used:

PHP, MySQL

Getting the current full URL in PHP

24
Mar
2010

Sometimes, you might want to get the current full URL in PHP. Here is how you do that.

Add the following code to a page:

function selfURL(){
if(!isset($_SERVER['REQUEST_URI'])){
$serverrequri = $_SERVER['PHP_SELF'];
}else{
$serverrequri =    $_SERVER['REQUEST_URI'];
}
$s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
$protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
return $protocol."://".$_SERVER['SERVER_NAME'].$port.$serverrequri;
}
function strleft($s1, $s2) {
return substr($s1, 0, strpos($s1, $s2));
}

You can now get the full URL using the line:

print(selfURL());

NOTE: This function works with Apache + IIS