Re: [PHP] questions about $_SERVER

2012-03-19 Thread tamouse mailing lists
On Sat, Mar 10, 2012 at 7:43 PM, Tedd Sperling wrote: > On Mar 10, 2012, at 3:53 PM, tamouse mailing lists wrote: >> On Sat, Mar 10, 2012 at 9:37 AM, Tedd Sperling >> wrote: >>> That's correct, but to access those variables outside of their scope (such >>> as a function) you do via a SuperGloba

Re: [PHP] questions about $_SERVER

2012-03-13 Thread Donovan Brooke
Stuart Dallas wrote: [snip] so $GLOBALS['GLOBALS']['GLOBALS']['GLOBALS']['_SERVER'] is a perfectly valid, if daft, way of accessing $_SERVER. -Stuart Now this is becoming educational! ;-) Donovan -- D Brooke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http:/

Re: [PHP] questions about $_SERVER

2012-03-13 Thread Tim Streater
On 13 Mar 2012 at 15:59, Tedd Sperling wrote: > I'm not sure what would have saved bacon in the above case. I don't see how > your example would work. I think it contained a typo. > > In what I think you were trying to demonstrate, I would just pass $x by > reference (&$x) -- or -- return $x by

Re: [PHP] questions about $_SERVER

2012-03-13 Thread Tedd Sperling
On Mar 13, 2012, at 12:20 PM, Stuart Dallas wrote: > On 13 Mar 2012, at 15:59, Tedd Sperling wrote: > >> In any event, I seldom use globals anyway. This was more an academic >> discussion. > -snip- > It ultimately also means that only the superglobals are true globals. That was my initial statem

Re: [PHP] questions about $_SERVER

2012-03-13 Thread Stuart Dallas
On 13 Mar 2012, at 15:59, Tedd Sperling wrote: > In any event, I seldom use globals anyway. This was more an academic > discussion. If you're being academic about it please remember that the way PHP defines globals is different to most other languages. PHP: A variable defined at the top-level

Re: [PHP] questions about $_SERVER

2012-03-13 Thread Matijn Woudt
On Tue, Mar 13, 2012 at 4:59 PM, Tedd Sperling wrote: > On Mar 12, 2012, at 7:12 PM, Tim Streater wrote: >> > >> function yes ($a) >>     { >>     global $x; >>     if  ($a)  $x = "yes\n"; >>     } >> >> first (true); >> >> echo $x; >> >> ?> >> >> >> but I haven't looked into $GLOBALS enough to kn

Re: [PHP] questions about $_SERVER

2012-03-13 Thread Tedd Sperling
On Mar 12, 2012, at 12:04 PM, Daniel Brown wrote: > On Sun, Mar 11, 2012 at 14:16, Tedd Sperling wrote: >> This document clearly states that $GLOBALS is a SuperGlobal -- what am I not >> understanding here? > >You are understanding it correctly, the only thing that's missing > is the populat

Re: [PHP] questions about $_SERVER

2012-03-13 Thread Tedd Sperling
On Mar 12, 2012, at 7:12 PM, Tim Streater wrote: > > function yes ($a) > { > global $x; > if ($a) $x = "yes\n"; > } > > first (true); > > echo $x; > > ?> > > > but I haven't looked into $GLOBALS enough to know whether using them instead > would have saved my bacon. I'm no

Re: [PHP] questions about $_SERVER

2012-03-12 Thread Tim Streater
On 12 Mar 2012 at 20:07, Tedd Sperling wrote: > Tim: > > I read somewhere that using: > > global $x; > > is not recommended. Whereas, it is recommended to use: > > $x = $GLOBALS['x']; > echo $x; Tedd, That may well be, although as I write I can't recollect having seen that anywhere; so I don'

Re: [PHP] questions about $_SERVER

2012-03-12 Thread Jim Giner
The purpose of the "global" statement within a function is to let PHP know that the usage of a var name INSIDE that function is not meant to create a NEW variable, but instead, to reference the other (global) variable being used (and perhaps already defined) in your main script. Basically it wo

Re: [PHP] questions about $_SERVER

2012-03-12 Thread Tedd Sperling
On Mar 11, 2012, at 3:04 PM, Tim Streater wrote: > > In the following, $x is a global but not a super-global (AFAIK). > > > > function echox () > { > > global $x; > > echo $x; > > } > > $x = "Hello world\n"; > > echox (); > > ?> > > -- > Cheers -- Tim Tim: I read so

Re: [PHP] questions about $_SERVER

2012-03-12 Thread Daniel Brown
On Sun, Mar 11, 2012 at 14:16, Tedd Sperling wrote: > > As to placing an additional requirement (i.e., being predefined) on the > definition as to what constitutes a SuperGlobal is outside my understanding. > As such, I must defer to the PHP Manual, namely: > > http://php.net/manual/en/language.

Re: [PHP] questions about $_SERVER

2012-03-11 Thread Tim Streater
On 11 Mar 2012 at 18:16, Tedd Sperling wrote: > On Mar 11, 2012, at 10:25 AM, Daniel Brown wrote: > >> On Sat, Mar 10, 2012 at 10:37, Tedd Sperling wrote: >>> As such, there are no "globals" in PHP other than SuperGlobals. As I said, >>> if I'm wrong, please show me otherwise. >> >>A superg

Re: [PHP] questions about $_SERVER

2012-03-11 Thread Tedd Sperling
On Mar 11, 2012, at 10:25 AM, Daniel Brown wrote: > On Sat, Mar 10, 2012 at 10:37, Tedd Sperling wrote: >> As such, there are no "globals" in PHP other than SuperGlobals. As I said, >> if I'm wrong, please show me otherwise. > >A superglobal is predefined at run-time by the parser, > enviro

Re: [PHP] questions about $_SERVER

2012-03-11 Thread Daniel Brown
On Sat, Mar 10, 2012 at 10:37, Tedd Sperling wrote: > As such, there are no "globals" in PHP other than SuperGlobals. As I said, if > I'm wrong, please show me otherwise. A superglobal is predefined at run-time by the parser, environment, SAPI, etc. (_SERVER, _POST, _GET, _REQUEST, _ENV, _SE

Re: [PHP] questions about $_SERVER

2012-03-11 Thread Stuart Dallas
On 11 Mar 2012, at 01:43, Tedd Sperling wrote: > On Mar 10, 2012, at 3:53 PM, tamouse mailing lists wrote: >> On Sat, Mar 10, 2012 at 9:37 AM, Tedd Sperling >> wrote: >>> That's correct, but to access those variables outside of their scope (such >>> as a function) you do via a SuperGlobal, name

Re: [PHP] questions about $_SERVER

2012-03-10 Thread Tedd Sperling
On Mar 10, 2012, at 3:53 PM, tamouse mailing lists wrote: > On Sat, Mar 10, 2012 at 9:37 AM, Tedd Sperling > wrote: >> That's correct, but to access those variables outside of their scope (such >> as a function) you do via a SuperGlobal, namely $GLOBAL['whatever']. >> >> As such, there are no "

Re: [PHP] questions about $_SERVER

2012-03-10 Thread tamouse mailing lists
On Sat, Mar 10, 2012 at 9:37 AM, Tedd Sperling wrote: > On Mar 9, 2012, at 10:20 PM, Jim Giner wrote: >> "tamouse mailing lists" wrote in message >> news:CAHUC_t8g43GE3xqvSU5SwFePGS1XG=tk1mhrbem9gjaarve...@mail.gmail.com... >>> On Mon, Feb 13, 2012 at 2:39 PM, Tedd Sperling >>> wrote: On Fe

Re: [PHP] questions about $_SERVER

2012-03-10 Thread Jim Giner
"Tedd Sperling" wrote in message news:315faa8f-3103-4661-b167-d30248952...@gmail.com... On Mar 9, 2012, at 10:20 PM, Jim Giner wrote: > "tamouse mailing lists" wrote in message > news:CAHUC_t8g43GE3xqvSU5SwFePGS1XG=tk1mhrbem9gjaarve...@mail.gmail.com... >> On Mon, Feb 13, 2012 at 2:39 PM, Tedd

Re: [PHP] questions about $_SERVER

2012-03-10 Thread Tedd Sperling
On Mar 9, 2012, at 10:20 PM, Jim Giner wrote: > "tamouse mailing lists" wrote in message > news:CAHUC_t8g43GE3xqvSU5SwFePGS1XG=tk1mhrbem9gjaarve...@mail.gmail.com... >> On Mon, Feb 13, 2012 at 2:39 PM, Tedd Sperling >> wrote: >>> On Feb 13, 2012, at 4:10 AM, Stuart Dallas wrote: On 13 Feb

Re: [PHP] questions about $_SERVER

2012-03-09 Thread Jim Giner
"tamouse mailing lists" wrote in message news:CAHUC_t8g43GE3xqvSU5SwFePGS1XG=tk1mhrbem9gjaarve...@mail.gmail.com... > On Mon, Feb 13, 2012 at 2:39 PM, Tedd Sperling > wrote: >> On Feb 13, 2012, at 4:10 AM, Stuart Dallas wrote: >>> On 13 Feb 2012, at 06:28, Rui Hu wrote: How PHP sets varia

Re: [PHP] questions about $_SERVER

2012-03-09 Thread tamouse mailing lists
On Mon, Feb 13, 2012 at 2:39 PM, Tedd Sperling wrote: > On Feb 13, 2012, at 4:10 AM, Stuart Dallas wrote: >> On 13 Feb 2012, at 06:28, Rui Hu wrote: >>> How PHP sets variables in $_SERVER, say, $DOCUMENT_ROOT? What should I know >>> if I want to modify $_SERVER myself? >> >> Once your script start

Re: [PHP] questions about $_SERVER

2012-02-13 Thread Tedd Sperling
On Feb 13, 2012, at 4:10 AM, Stuart Dallas wrote: > On 13 Feb 2012, at 06:28, Rui Hu wrote: > >> How PHP sets variables in $_SERVER, say, $DOCUMENT_ROOT? What should I know >> if I want to modify $_SERVER myself? > > Once your script starts the superglobals are no different to any other > varia

Re: [PHP] questions about $_SERVER

2012-02-13 Thread Stuart Dallas
On 13 Feb 2012, at 06:28, Rui Hu wrote: > How PHP sets variables in $_SERVER, say, $DOCUMENT_ROOT? What should I know > if I want to modify $_SERVER myself? Once your script starts the superglobals are no different to any other variables, except that they're in scope at all times. The only thi

Re: [PHP] questions about $_SERVER

2012-02-12 Thread Michael Save
On Mon, Feb 13, 2012 at 5:28 PM, Rui Hu wrote: > hi, > > How PHP sets variables in $_SERVER, say, $DOCUMENT_ROOT? What should I know > if I want to modify $_SERVER myself? > > Thanks! > > > -- > Best regards, > > Rui Hu >

Re: [PHP] Questions about $_SERVER

2010-09-03 Thread tedd
Peter and Paul: Sorry, I went on vacation for a few days (it was a surprise vacation with a 2 day notice). I think you both understand what I was looking for and found what I wanted was not possible. It's just one of those things in life you have to live with. Thanks very much for your tim

Re: [PHP] Questions about $_SERVER

2010-08-30 Thread Paul M Foster
On Mon, Aug 30, 2010 at 05:13:59PM -0400, Paul M Foster wrote: > On Mon, Aug 30, 2010 at 10:34:42PM +0200, Peter Lind wrote: > > > On 30 August 2010 22:34, Paul M Foster wrote: > > > On Mon, Aug 30, 2010 at 09:53:46PM +0200, Peter Lind wrote: > > > > > > > > >> > $_SERVER['REMOTE_NAME'] > > >

Re: [PHP] Questions about $_SERVER

2010-08-30 Thread Paul M Foster
On Mon, Aug 30, 2010 at 10:34:42PM +0200, Peter Lind wrote: > On 30 August 2010 22:34, Paul M Foster wrote: > > On Mon, Aug 30, 2010 at 09:53:46PM +0200, Peter Lind wrote: > > > >> > $_SERVER['REMOTE_NAME'] > >> > > >> > So the question is, how would he get that last variable. It becomes > >>

Re: [PHP] Questions about $_SERVER

2010-08-30 Thread Peter Lind
On 30 August 2010 22:34, Paul M Foster wrote: > On Mon, Aug 30, 2010 at 09:53:46PM +0200, Peter Lind wrote: > >> On 30 August 2010 21:32, Paul M Foster wrote: >> > On Sun, Aug 29, 2010 at 06:04:23PM +0200, Per Jessen wrote: >> > >> >> Jason Pruim wrote: >> >> >> >> > My understanding of how share

Re: [PHP] Questions about $_SERVER

2010-08-30 Thread Paul M Foster
On Mon, Aug 30, 2010 at 09:53:46PM +0200, Peter Lind wrote: > On 30 August 2010 21:32, Paul M Foster wrote: > > On Sun, Aug 29, 2010 at 06:04:23PM +0200, Per Jessen wrote: > > > >> Jason Pruim wrote: > >> > >> > My understanding of how shared hosting works would make this near > >> > impossible..

Re: [PHP] Questions about $_SERVER

2010-08-30 Thread Peter Lind
On 30 August 2010 21:32, Paul M Foster wrote: > On Sun, Aug 29, 2010 at 06:04:23PM +0200, Per Jessen wrote: > >> Jason Pruim wrote: >> >> > My understanding of how shared hosting works would make this near >> > impossible... Basically Apache grabs a header that is sent at the >> > initial connecti

Re: [PHP] Questions about $_SERVER

2010-08-30 Thread Paul M Foster
On Sun, Aug 29, 2010 at 06:04:23PM +0200, Per Jessen wrote: > Jason Pruim wrote: > > > My understanding of how shared hosting works would make this near > > impossible... Basically Apache grabs a header that is sent at the > > initial connection which includes the destination hostname and from >

Re: [PHP] Questions about $_SERVER

2010-08-29 Thread Peter Lind
On 29 August 2010 18:04, Per Jessen wrote: > Jason Pruim wrote: > >> My understanding of how shared hosting works would make this near >> impossible... Basically Apache grabs a header that is sent at the >> initial connection which includes the destination hostname and from >> there it translates

Re: [PHP] Questions about $_SERVER

2010-08-29 Thread Per Jessen
Jason Pruim wrote: > My understanding of how shared hosting works would make this near > impossible... Basically Apache grabs a header that is sent at the > initial connection which includes the destination hostname and from > there it translates it to the proper directory on the shared host. > >

Re: [PHP] Questions about $_SERVER

2010-08-29 Thread tedd
At 11:54 AM -0400 8/29/10, Jason Pruim wrote: On Aug 29, 2010, at 10:55 AM, tedd wrote: To all: My post about SERVER globals was simply an observation that the SERVER global report of host and remote was not symmetric -- for example you could obtain both the IP and Domain Name of the host,

Re: [PHP] Questions about $_SERVER

2010-08-29 Thread Jason Pruim
On Aug 29, 2010, at 10:55 AM, tedd wrote: At 10:56 AM +0200 8/29/10, Peter Lind wrote: On 29 August 2010 08:08, Jim Lucas wrote: *snip* Their is not existing variable (if you would) that your server, when connecting to a remote server, would be sending. So, to have the remote end be abl

Re: [PHP] Questions about $_SERVER

2010-08-29 Thread tedd
At 10:56 AM +0200 8/29/10, Peter Lind wrote: On 29 August 2010 08:08, Jim Lucas wrote: *snip* Their is not existing variable (if you would) that your server, when connecting to a remote server, would be sending. So, to have the remote end be able to identify the initiating host identity,

Re: [PHP] Questions about $_SERVER

2010-08-29 Thread Peter Lind
On 29 August 2010 08:08, Jim Lucas wrote: *snip* > Their is not existing variable (if you would) that your server, when > connecting to a remote server, would be sending.  So, to have the remote end > be able to identify the initiating host identity, the initiating side would > have to add some

Re: [PHP] Questions about $_SERVER

2010-08-28 Thread Jim Lucas
tedd wrote: At 12:15 AM +0200 8/29/10, Peter Lind wrote: On 28 August 2010 23:45, tedd wrote: > So, I'm trying to figure out a compliment to $_SERVER['SERVER_NAME'] such as something like $_SERVER['REMOTE_NAME']. > Is there such a beast? You're not making any sense. For the script on y

Re: [PHP] Questions about $_SERVER

2010-08-28 Thread Tamara Temple
Sorry, forgot to include the mailing list email when I replied to this originally... On Aug 28, 2010, at 8:28 PM, tedd wrote: Sorry for not making sense. But sometimes you have to confirm the players (both server and remote) in communications. Try this -- place this script on your site:

Re: [PHP] Questions about $_SERVER

2010-08-28 Thread tedd
At 12:15 AM +0200 8/29/10, Peter Lind wrote: On 28 August 2010 23:45, tedd wrote: > So, I'm trying to figure out a compliment to $_SERVER['SERVER_NAME'] such as something like $_SERVER['REMOTE_NAME']. > Is there such a beast? You're not making any sense. For the script on your local hos

Re: [PHP] Questions about $_SERVER

2010-08-28 Thread Peter Lind
On 28 August 2010 23:45, tedd wrote: > At 9:41 PM +0200 8/28/10, Per Jessen wrote: >> >> tedd wrote: >>  > >>> >>>  So, how can I identify the exact location of the 'server_addr' and of >>>  the 'remote_addr' on shared hosting? Is that possible? >> >> $_SERVER['SERVER_NAME'] will tell you the name

Re: [PHP] Questions about $_SERVER

2010-08-28 Thread tedd
At 9:41 PM +0200 8/28/10, Per Jessen wrote: tedd wrote: > So, how can I identify the exact location of the 'server_addr' and of the 'remote_addr' on shared hosting? Is that possible? $_SERVER['SERVER_NAME'] will tell you the name of the virtual host - I don't know if that is what you're aft

Re: [PHP] Questions about $_SERVER

2010-08-28 Thread Per Jessen
tedd wrote: > Hi gang: > > The server global: > > $_SERVER['SERVER_ADDR'] > > Provides the IP of the server where the current script is executing. > > And, the server global: > > $_SERVER['REMOTE_ADDR'] > > Provides the IP of the server executing the script. Yes, aka the client addr

[PHP] Questions about $_SERVER

2010-08-28 Thread tedd
Hi gang: The server global: $_SERVER['SERVER_ADDR'] Provides the IP of the server where the current script is executing. And, the server global: $_SERVER['REMOTE_ADDR'] Provides the IP of the server executing the script. As such, you can enter the IP of either into a browser and see t