$_SERVER["PHP_SELF"] timeout

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

This has me baffled:

I've got a simple piece of code-

<?php
 
echo ($_SERVER[\"PHP_SELF\"]);
?>

Other $_SERVER indexes show up fine, but this locks up a bit and ends after 30 seconds.

I'm running Xitami with PHP 4.2.2 on WinXP.

Ideas? Need more details?

Thanks. Wink

Busy's picture

He has: 6,151 posts

Joined: May 2001

tried single quotes

echo ($_SERVER['PHP_SELF']);

or without the brackets

echo $_SERVER["PHP_SELF"];

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Tried both. Same result. Sad

Thanks anyway. Smiling

dk01's picture

He has: 516 posts

Joined: Mar 2002

Why not just use $PHP_SELF ?
-dk

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Can you access it via $GLOBALS["PHP_SELF"] or $HTTP_SERVER_VARS["PHP_SELF"] ?

And what is Xitami?

hagar's picture

They have: 104 posts

Joined: Oct 2002

its an open source webserver
http://www.xitami.com/

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Have you tried the same script using Apache on the same box?
Do you still have the same problem?

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

dk01, $PHP_SELF is an undefined variable.

Mark, I've just tried $HTTP_SERVER_VARS and $GLOBALS. $HTTP_SERVER_VARS gives me a timeout. $GLOBALS gives an undefined index error.

In any case, this isn't a big deal. What I really need for now is to use SERVER_NAME, and that works, so it's ok.

I don't have Apache but I'm going to install it soon. Maybe PHP_SELF will work in that environment. I use Xitami because it's a handy little program, and is hardly a resource hog. It's like a good working version of PWS, that supports CGI/PHP. Simply, it does what it's supposed to do. (Well, until now, of course. Wink)

He has: 1,016 posts

Joined: May 2002

Abhi, from what I've understood $_SERVER["PHP_SELF"] (aka $PHP_SELF) works only with Apache. For other webservers you should try $_SERVER["SCRIPT_NAME"] (aka $SCRIPT_NAME).

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

After reading zollet's post, I had to check the manual... (I didn't remember anything about 'SCRIPT_NAME')

Quote:
'PHP_SELF'
The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar.

If PHP is running as a command-line processor, this variable is not available.

'SCRIPT_NAME'
Contains the current script's path. This is useful for pages which need to point to themselves.

From that, I'm guessing that Xitami is running *.php files from a command-line (like a shell), and returning the output.

Mark Hensler
If there is no answer on Google, then there is no question.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

It works. I never knew of SCRIPT_NAME. Smiling

Thanks, guys. Wink

Busy's picture

He has: 6,151 posts

Joined: May 2001

Abhishek if you or anyone else wants the bundle php/mysql/apache/perl/mysql + manuals check out firepages.com.au

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Wow, thanks for that. Smiling

I haven't visited firepages since... what, about two years ago? fp has sure done a lot of work. Smiling

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.