1

I have this URL lets say:

www.abc.com/item?id=10

When ever I do this:

echo $_SERVER['PHP_SELF']

I get only:

www.abc.com

How do I get the whole URL with appended variable?

RPichioli
  • 3,245
  • 2
  • 25
  • 29
Alexis
  • 209
  • 1
  • 4
  • 11

2 Answers2

0

use $_SERVER['REQUEST_URI'] as follows

echo "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
/* Or */
echo $_SERVER['REQUEST_SCHEME']."://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
Dev. Joel
  • 1,127
  • 1
  • 9
  • 14
0

You can try to take the full URL with: (for example)

<?php echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>

Good topics:

Community
  • 1
  • 1
RPichioli
  • 3,245
  • 2
  • 25
  • 29