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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
* 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." |
|
|||
|
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 |
|
|||
|
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 */ |
|
|||
|
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']; |
|
|||
|
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? |