djsoltan
asked on
php url
hi,
can anyone tell me how i can echo the entire url of the page using php?
for example: <?php echo url ?>
result would be like
http://mysite.com/music.php?id=100
i guess there is a global variable that can be used, but i dono what it is.
thanks
can anyone tell me how i can echo the entire url of the page using php?
for example: <?php echo url ?>
result would be like
http://mysite.com/music.php?id=100
i guess there is a global variable that can be used, but i dono what it is.
thanks
ASKER
hi,
well i want it to be automatic,,,
so that it makes it on the fly based on the id
i dont want to hard code it for everysingle page since there are so many of them.
so if there is a value that would findout what the current url is, and just echo the entire url would be great.
well i want it to be automatic,,,
so that it makes it on the fly based on the id
i dont want to hard code it for everysingle page since there are so many of them.
so if there is a value that would findout what the current url is, and just echo the entire url would be great.
you want to echo the url of the current page ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try:
$uri=$_SERVER[PHP_SELF];
echo( "<a href='{$uri}'>{$uri}</a>") ;
If that does not work try:
$uri=$_SERVER[PHP_SELF];
echo( "<a href='" . $uri . "'>".$uri."</a>");
$uri=$_SERVER[PHP_SELF];
echo( "<a href='{$uri}'>{$uri}</a>")
If that does not work try:
$uri=$_SERVER[PHP_SELF];
echo( "<a href='" . $uri . "'>".$uri."</a>");
I had hoped at first that PHP_SELF would work, but I think it only gives a relative URL.
if you want it to be a clickable link
<?php echo "<a href='http://mysite.com/music.php?id=100'>http://mysite.com/music.php?id=100</a>" ?>