Posted by Michael Fesser on 11/14/07 17:07
..oO(Rob Wilkerson)
>> That's how singletons work in PHP.
>
>That's what I was afraid of. Kind of makes singletons worthless (at
>least for my case), doesn't it?
Partly. But they still assure that there's only a single instance to
work with, which is globally available from everywhere in your scripts.
>I could assign a new instance to a
>variable and just reference that variable through the life of the
>request. In the case of my (xml-based) config, I have to read the
>config on every single request. I was hoping to avoid that without
>using flat files or the session scope.
That's simply because of how PHP works:
init -> request -> response -> done
init -> request -> response -> done
....
To keep data available for several requests you would either need a real
application server:
init
request -> response
request -> response
....
done
which is not yet available for PHP (except for some experimental
projects) or you could have a look at shared memory.
Micha
[Back to original message]
|