$_SERVER (as well as all the $_* functions) in PHP 4.1 are automatically
global.

--
Aaron Gould
[EMAIL PROTECTED]
Web Developer


----- Original Message -----
From: "Alastair Battrick" <[EMAIL PROTECTED]>
To: "Erik Price" <[EMAIL PROTECTED]>; "Darren Gamble"
<[EMAIL PROTECTED]>
Cc: "PHP" <[EMAIL PROTECTED]>
Sent: Thursday, February 14, 2002 10:46 AM
Subject: RE: [PHP] how a function 'return' statement works


> Do you not have to make $_SERVER a global variable in the function ?
>
> Alastair
> Lightwood Consultancy Ltd
>
> > Hm... I tried quite a few variations on this.  I can't seem to get any
> > displayable value out of this function.
> >
> > function get_current_page_name()
> > {
> > $current_page_name = explode("/", $_SERVER['PHP_SELF']);
> > $current_page_name = $current_page_name[-1];
> > return $current_page_name ;
> > }
> >
> > $errorcode = get_current_page_name();
> > echo $errorcode;
> >
> > Nothing.
> >
> > The only thing that works is $errorcode =
> > basename($_SERVER['PHP_SELF']), but that's not the point -- I still
> > don't understand why the function above doesn't return anything.  In
> > this case, I'm positive that I've specified the last element of the
> > array.  (Haven't I?)
> >
> >
> > Erik
> >
> >
> >
> >
> > On Wednesday, February 13, 2002, at 05:03  PM, Darren Gamble wrote:
> >
> > > I think what you're trying to do is return one particular element out
> > > of the
> > > array.  If that's the case, just use something like:
> > >
> > > return $current_page_name[-1]
> > >
> > > to return the last element in the array.
> > >
> > > ============================
> >
> > ----
> >
> > Erik Price
> > Web Developer Temp
> > Media Lab, H.H. Brown
> > [EMAIL PROTECTED]
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to