is there any Drupal built-in function to get the current full URL?

thanks a lot.

Comments

jbomb’s picture

you could try request_uri() ... you might also need $_SERVER['HTTP_HOST']

// i haven't tested this
$uri = $_SERVER['HTTP_HOST'] . '/' . request_uri();
print $uri;
WorldFallz’s picture

I'm not aware of a drupal function for this, but it's easy enough with PHP:

<?php
$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; 
print $url;
?>

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

newaira’s picture

echo url(NULL, array('absolute' => TRUE));
navi85sin’s picture

To get the host name like http://www.yourdonmainname.com

use

Global $base_url;
$base_url;

print_r($base_url);

will give u http://www.yourdonmainname.com

u can extend this by $url=$base_url.path_to_theme();

to get full path to theme.

for module path u can use drupal_get_path('module', 'screencast')

also check base_path() by using the print_r(base_path());

dxx’s picture

to get full url with the base_url has prefix:

print url('node/NID', array('absolute' => TRUE));