$_SERVER

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Haku
Forum Newbie
Posts: 3
Joined: Thu Aug 19, 2004 4:28 pm
Location: Canada

$_SERVER

Post by Haku »

Hi,

What is the difference in the behaviour of the php code below:
(Assume the current page is reload.php and by reloading the page, we want to update certain values)

Code: Select all

<form action = "<?=$_SERVER['PHP_SELF']?> method = "post">
and

<form action = "reload.php" method = "post">

Thank you very much,
-Haku-
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

the first is simply more adaptable. if you change the location of the page, you don't need to edit the code to change the path...
User avatar
William
Forum Contributor
Posts: 332
Joined: Sat Oct 25, 2003 4:03 am
Location: New York City

Post by William »

Ya, Makes it really nice specially if your including the file .ect
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Yes either that or use a central const.php file that stores the location of the processing pages. So if indeed you move your site, you can edit the central constant variable file and all is well again.
Post Reply