Bluehost.com Web Hosting $6.95

RE: [PHP] $_SELF[PHP_SELF] not working anymore

This is a discussion on RE: [PHP] $_SELF[PHP_SELF] not working anymore within the PHP General forums, part of the PHP Programming Forums category; Try with $_SERVER["PHP_SELF"] -----Mensaje original----- De: Maria Garcia Suarez [mailto:mariagarciasuarez@yahoo.com] Enviado el: martes, 16 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-16-2003
Javier Tacon
 
Posts: n/a
Default RE: [PHP] $_SELF[PHP_SELF] not working anymore


Try with $_SERVER["PHP_SELF"]


-----Mensaje original-----
De: Maria Garcia Suarez [mailto:mariagarciasuarez@yahoo.com]
Enviado el: martes, 16 de septiembre de 2003 15:26
Para: php-general@lists.php.net
Asunto: [php] $_SELF[PHP_SELF] not working anymore
Importancia: Baja


Hi there!

I'm currently developing some pages where I use
$_SELF[PHP_SELF], always without any kind of problem
(until some days ago).

Some days ago, as I said, I formated my hard disk,
installed everything again and from that day on
$_SELF[PHP_SELF] stopped working, same goes for
$_SERVER[REQUEST_URI] or $_GET[location] (which are
the solution I tried to find, without success). The
page says:

Notice: Undefined index

(for $_GET) or it just says nothing (the other ones
above, no error reported, it just displays nothing).

Inside PHP.ini I have globals set to On, but if I set
them to Off nothing changes...

Can anyone help me? At PHP.net I saw "If PHP is
running as a command-line processor, this variable is
not available", but I am running it from a web page on
Windows 2000 + Xitami.

Thanks a lot for your help and sorry if I asked
something stupid, but I couldn't find any solution....

Kisses,
Maria

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Reply With Quote
  #2 (permalink)  
Old 09-16-2003
Curt Zirzow
 
Posts: n/a
Default Re: [PHP] RE: $_SELF[PHP_SELF] not working anymore

* Thus wrote Maria Garcia Suarez (mariagarciasuarez@yahoo.com):
> Hi there!
>
> --- Javier Tacon <javier.tacon@private.com> wrote:
>
> > Try with $_SERVER["PHP_SELF"]

>
> Then I get:
>
> Parse error: parse error, unexpected
> T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or
> T_VARIABLE or T_NUM_STRING in
>
> This is how I use it:
> $currentAddress="$_SERVER[HTTP_HOST]$_SERVER[PHP_SELF]";


You should always quote your array keys (cept if all the keys are
numeric. Also when inside a string, enclose your variables with
{}.

$currentAddress="{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";


php wont be so confused as what you're trying to do.

Curt
--
"I used to think I was indecisive, but now I'm not so sure."
Reply With Quote
  #3 (permalink)  
Old 09-16-2003
Maria Garcia Suarez
 
Posts: n/a
Default Re: $_SELF[PHP_SELF] not working anymore

Hi there!

First, thanks for your reply...

--- Curt Zirzow <php-general@zirzow.dyndns.org> wrote:
> * Thus wrote Maria Garcia Suarez
> (mariagarciasuarez@yahoo.com):
> > > Try with $_SERVER["PHP_SELF"]

> > Then I get:
> > Parse error: parse error, unexpected
> > T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or
> > T_VARIABLE or T_NUM_STRING in
> > This is how I use it:

$currentAddress="$_SERVER[HTTP_HOST]$_SERVER[PHP_SELF]";
> You should always quote your array keys (cept if all
> the keys are
> numeric. Also when inside a string, enclose your
> variables with
> {}.

$currentAddress="{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";
> php wont be so confused as what you're trying to do.


I also tried with $_SERVER[PHP_SELF] alone (echo
"$_SERVER[PHP_SELF]"; or echo
"$_SERVER['PHP_SELF']";), and it doesn't work. I
personally don't think PHP is confused about what I'm
trying to do...

Thanks anyway.

Do you have any other idea? I already ran out of
them... :-(

Kisses,
Maria

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
Reply With Quote
  #4 (permalink)  
Old 09-16-2003
Jason Wong
 
Posts: n/a
Default Re: [PHP] Re: $_SELF[PHP_SELF] not working anymore

On Tuesday 16 September 2003 23:45, Maria Garcia Suarez wrote:

> $currentAddress="{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";
>
> > php wont be so confused as what you're trying to do.


Does the above not work?

> I also tried with $_SERVER[PHP_SELF] alone (echo
> "$_SERVER[PHP_SELF]"; or echo
> "$_SERVER['PHP_SELF']";), and it doesn't work. I
> personally don't think PHP is confused about what I'm
> trying to do...


What does "and it doesn't work" actually mean? There's no output? There's an
error message? The monitor explodes?

> Do you have any other idea? I already ran out of
> them... :-(


What version of PHP are you using? Have you turned on all error reporting? And
what does

print_r($_SERVER);

give you?

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
A program generator creates programs that are more ``buggy'' than the program
generator.
-- The Last One's Law of Program Generators
*/
Reply With Quote
  #5 (permalink)  
Old 09-16-2003
Eugene Lee
 
Posts: n/a
Default Re: [PHP] RE: $_SELF[PHP_SELF] not working anymore

On Tue, Sep 16, 2003 at 03:30:39PM +0000, Curt Zirzow wrote:
: * Thus wrote Maria Garcia Suarez (mariagarciasuarez@yahoo.com):
: > --- Javier Tacon <javier.tacon@private.com> wrote:
: >
: > > Try with $_SERVER["PHP_SELF"]
: >
: > Then I get:
: >
: > Parse error: parse error, unexpected
: > T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or
: > T_VARIABLE or T_NUM_STRING in
: >
: > This is how I use it:
: > $currentAddress="$_SERVER[HTTP_HOST]$_SERVER[PHP_SELF]";
:
: You should always quote your array keys (cept if all the keys are
: numeric. Also when inside a string, enclose your variables with
: {}.
:
: $currentAddress="{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";

How about:

$currentAddress = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
Reply With Quote
  #6 (permalink)  
Old 09-17-2003
Gary Petersen
 
Posts: n/a
Default Re: [PHP] RE: $_SELF[PHP_SELF] not working anymore

On Tue, 16 Sep 2003 10:30:39 -0500, Curt Zirzow created an award-winning
crop circle <20030916153039.GT4251@bagend.shire>, which, when translated
into English, means this:

>
> You should always quote your array keys (cept if all the keys are
> numeric. Also when inside a string, enclose your variables with {}.
>
> $currentAddress="{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";
>
>
> php wont be so confused as what you're trying to do.
>
> Curt


Huh?
I thought that the array key does not have to
be quoted if it's in a double-quoted string; here
is a program I made to test it:

1 <?php
2 // PHP 4.0.5
3 error_reporting(E_ALL);
4
5 define ('SIX', 6);
6 $arr[SIX] = 'six word';
7 // $arr['SIX'] = 'String of six';
8
9 // Generates an error; the key is assumed correctly to
10 // be a string
11 echo "<p>Show 1: $arr[SIX] (should show 'String of six')</p>\n";
12
13 // Performs okay; the key is assumed correctly to
14 // be a constant.
15 echo "<p>Show 2: {$arr[SIX]} (should show 'six word')</p>\n";
16
17 // There is no ambiguity between
18 // "$arr[<CONSTANT>]" and "$arr[<STRING>]"
19 // since $arr[<CONSTANT>] must be placed
20 // inside of braces {}
21 ?>

Depending upon which line is commented out (between
lines 6 and 7), either line 11 or line 15 will generate
an error.

If $arr[SIX] does not exist, PHP (4.0.5) does not assume
that the programmer means $arr['SIX'].

And if $arr['SIX'] does not exist, PHP does not assume
that the programmer means $arr[SIX]--no ambiguity.

If it is done in a quoted string, leaving the quotes
off the key is safe. However, because I'm using an
antiquated version of PHP, I don't know if the behavior
is different for newer versions of PHP. So, can anyone
tell me how later versions act wrt this?

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 02:24 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0