Re: how a function 'return' statement works
| From: | DL Neil | Date: | Thu, 14 Feb 2002 16:37:10 +0000 |
| Subject: | Re: how a function 'return' statement works | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-84761@lists.php.net to get a copy of this message | ||
Erik,
> 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;
>
> 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?)
Some extra debug echo statements will (dis)prove this...
=dn