Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

$PHP_SELF doesnt work for me

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

$PHP_SELF doesnt work for me

Postby jbn » Sun Dec 29, 2002 10:47 am

I have installed apache 1.3.27 with PHP 4.3.0RC3 and when I use
$PHP_SELF in the code it doesnt work, why?
do I need to use some extra syntax when configuring for this to work or?
jbn
New php-forum User
New php-forum User
 
Posts: 4
Joined: Sun Dec 29, 2002 10:32 am
Location: Sweden

Postby Joan Garnet » Sun Dec 29, 2002 1:33 pm

Post your code just in case there's a ayntax error.
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Postby jbn » Sun Dec 29, 2002 3:26 pm

well I dont have the code now but it doesnt appear when I do this
for example and it sould:
<?php
echo $PHP_SELF;
?>
jbn
New php-forum User
New php-forum User
 
Posts: 4
Joined: Sun Dec 29, 2002 10:32 am
Location: Sweden

Postby Joan Garnet » Sun Dec 29, 2002 5:06 pm

ok, in this case you need this -->
echo $_SERVER['PHP_SELF'];

But if you want to use it for links, just use this -->
Code: Select all
echo "<a href=".$PHP_SELF."?>click</a>";

Note that there is an interogant '?'. You need it to get right result, just as if you wanted to add HTTP variables.

bye
:)
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Postby jbn » Mon Dec 30, 2002 6:46 am

ok, thanks :D

this didnt work:

<?
echo "<a href=".$PHP_SELF.">click</a>";
?>

but this worked:

<?
echo "<a href=".$_SERVER["PHP_SELF"].">click</a>";
?>
jbn
New php-forum User
New php-forum User
 
Posts: 4
Joined: Sun Dec 29, 2002 10:32 am
Location: Sweden

Postby Joan Garnet » Mon Dec 30, 2002 1:47 pm

jbn wrote:ok, thanks :D

this didnt work:

<?
echo "<a href=".$PHP_SELF.">click</a>";
?>


Yes, I told you in the last post (Look at the note ) :)
You are missing the '?' -->
Look:
echo "<a href=".$PHP_SELF."?>click</a>";

This is the key
bye
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars


Return to PHP coding => General

Who is online

Users browsing this forum: Majestic-12 [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.