Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:5102 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61848 invoked by uid 1010); 30 Oct 2003 10:38:15 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 61824 invoked from network); 30 Oct 2003 10:38:14 -0000 Received: from unknown (HELO mail.zend.com) (192.117.235.230) by pb1.pair.com with SMTP; 30 Oct 2003 10:38:14 -0000 Received: (qmail 16274 invoked from network); 30 Oct 2003 10:38:00 -0000 Received: from guardian.zend.office (HELO andi-laptop.zend.com) (10.1.1.4) by int.zend.com with SMTP; 30 Oct 2003 10:38:00 -0000 Message-ID: <5.1.0.14.2.20031030123410.02b606a0@127.0.0.1> X-Sender: andi@127.0.0.1 X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Thu, 30 Oct 2003 12:35:23 +0200 To: Filip de Waard ,internals@lists.php.net In-Reply-To: <1067509592.3129.20.camel@gt0306.uvt.nl> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] superglobals inside of function declarations From: andi@zend.com (Andi Gutmans) References: <1067509592.3129.20.camel@gt0306.uvt.nl> Hi, In general you are only allowed to use scalars as default values. This won't change. I suggest you do something like: function refresh($location = NULL) { if ($location === NULL) { $location = $_SERVER['PHP_SELF']; } } At 11:26 AM 10/30/2003 +0100, Filip de Waard wrote: >Hello, > >I've been using PHP for quite a while now and i'm getting interested >it's internal beheaviour. I'm wondering why it isn't possible to use a >global variable inside of a function declaration. For example: > >function refresh($location = $_SERVER['PHP_SELF']) >{ > //refresh and load $location >} >//refreshes the page >refresh(); >//redirects to another page >refresh("http://www.php.net/"); >?> > >Of course there are ways to circumvent this problem that have the same >result, but require more code. IMHO allowing globals inside of function >declarions will create interesting possibilities that could result in >more efficient code. > >Regards, > >Filip de Waard >Net Collective > >www.netcollective.nl > >-- >PHP Internals - PHP Runtime Development Mailing List >To unsubscribe, visit: http://www.php.net/unsub.php