Re: [PEPr] Comment on Networking::Net_SMPP_Client
| From: | Justin Patrin | Date: | Sun, 24 Apr 2005 00:03:54 +0000 |
| Subject: | Re: [PEPr] Comment on Networking::Net_SMPP_Client | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-37385@lists.php.net to get a copy of this message | ||
On 4/23/05, Ian Eure <ieure@php.net> wrote:
> On Saturday 23 April 2005 12:11 pm, Nikolas Coukouma wrote:
> > Nikolas Coukouma (http://pear.php.net/user/atrus) has commented on the
> > proposal for Networking::Net_SMPP_Client.
> >
> > Comment:
> >
> > re: golbal variable for lookup:
> >
> > make the hash a static variable in a member function. For example:
> > class Foo {
> > function getHash() {
> > static hash = array( 1, 2 );
> > return hash;
> > }
> > }
> >
> I've never seen this trick before, and I don't see it documented anywhere in
> the PHP manual. Is this intended behavior, or a side-effect?
>
> I.e. will it continue to work?
>
This is perfectly legal and is basically the same as storing in
globals except that it doesn't clutter up the global namespace.
Static vars in functions are used so that you have one instance of a
var for all calls of the function. Look up the "static" keyword.
--
Justin Patrin