I can't see the value of $PHP_SELF. It has no value.HELP!

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
Wentu
Forum Newbie
Posts: 11
Joined: Sun Feb 02, 2003 1:09 pm

I can't see the value of $PHP_SELF. It has no value.HELP!

Post by Wentu »

I installed an ApacheSever and the latest PHP version.
Simple tests seemed ok but now i am trying to use the variable $PHP_SELF and it seems it doesn't exists. BUT, if i write

Code: Select all

echo "we are in:",$_SERVER&#1111;"PHP_SELF"],"<br>" ;
i correctly see the path of the file.

if i write

Code: Select all

echo "we are in:",$PHP_SELF,"<br>" ;
i just see "we are in" and then "Undefined variable: PHP_SELF"

i worked with php elsewhere and this always worked. Where is the problem ?

thank you so much

Wentu
Wentu
Forum Newbie
Posts: 11
Joined: Sun Feb 02, 2003 1:09 pm

Post by Wentu »

ok i answer to myself.
It was due to
- register_globals = Off

in the php.ini file.

Now the question is: is it so important to keep this value off ? How do I use $PHP_SELF value then ? haev i always to write "$_SERVER["PHP_SELF"] ? Why is this better coding ?

Or is the use itself of PHP_SELF to be deprecated ???

thank you for any valuable explanations

Wentu
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

The best reason for you as coder is that $PHP_SELF is deprecated and might not be supported in future versions of php, although I doubt it ;)
Wentu
Forum Newbie
Posts: 11
Joined: Sun Feb 02, 2003 1:09 pm

Post by Wentu »

$PHP_SELF is deprecated ?
oh...

so what should the *perfect_php_developer* do to send a form to the same page the form appears in and keep some portability ?

thankx again

Wentu
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Code: Select all

<?php
$PHP_SELF = $_SERVER['PHP_SELF'];
?>
would be my best bet. :wink:
Post Reply