PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > 'application' variables not available? Alternatives?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
'application' variables not available? Alternatives?

Réponse
 
LinkBack Outils de la discussion
Vieux 08/09/2007, 01h30   #1
david
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 'application' variables not available? Alternatives?

Hi

I am looking at converting a large project from ASP to PHP, and have read
that there is no equivalent of global.asa in PHP. It is probably easiest if
I describe the problem starting with how the ASP does it:

Project uses global.asa to load a lot of 'global' constants and variables
into memory. This includes translations for the web site in a number of
different languages. These are loaded from text files so that changing them
is easy. These items when loaded in global.asa are as if they are in an
associative array which is available to the whole application - it is not
destroyed when the page is destroyed!

Any ideas how I could handle this in PHP? The ASP method seems sensible, as
the data is much too big to load for every page, and too common to load only
when required. Holding it in memory and it having application wide scope
like this is fast. Loading only parts required at execution from, say, a
database would surely be too costly in db calls?

Anyone have any ideas about what I could do?

Many thanks, David
  Réponse avec citation
Vieux 08/09/2007, 03h07   #2
Vidyut Luther
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] 'application' variables not available? Alternatives?

Hi David,
I'd say your best bet is to use memcached. This will allow the
variables you specified to stay in memory, and be accessible to all
other applications.

http://www.danga.com/memcached/

Keep in mind though, just because ASP does it in one way, you don't want
to do a bit for bit copy. You could also look into options like the
auto_prepend feature in php.ini, and the define() function.

http://us2.php.net/define

I personally don't like using the auto_prepend feature, but it's there
and you could use it if you like, I'm a fan of implicitly requiring
files if I need to.

If your associative array, is really that large that it's going to slow
things down, you may also want to consider whether all your scripts need
all of the data, and then possibly define things that are only necessary
for certain classes, in the file for that class.

You can also serialize your associative array, and store it in the
database.. but it's really all dependant on what you need, and what the
app needs.



david wrote:
> Hi
>
> I am looking at converting a large project from ASP to PHP, and have read
> that there is no equivalent of global.asa in PHP. It is probably easiest if
> I describe the problem starting with how the ASP does it:
>
> Project uses global.asa to load a lot of 'global' constants and variables
> into memory. This includes translations for the web site in a number of
> different languages. These are loaded from text files so that changing them
> is easy. These items when loaded in global.asa are as if they are in an
> associative array which is available to the whole application - it is not
> destroyed when the page is destroyed!
>
> Any ideas how I could handle this in PHP? The ASP method seems sensible, as
> the data is much too big to load for every page, and too common to load only
> when required. Holding it in memory and it having application wide scope
> like this is fast. Loading only parts required at execution from, say, a
> database would surely be too costly in db calls?
>
> Anyone have any ideas about what I could do?
>
> Many thanks, David
>
>

  Réponse avec citation
Vieux 08/09/2007, 11h44   #3
david
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] 'application' variables not available? Alternatives?

Thanks very much for that Vidyet. This is going to be a massive .


"Vidyut Luther" <vidluther@gmail.com> wrote in message
news:46E1F5B5.60102@gmail.com...
> Hi David,
> I'd say your best bet is to use memcached. This will allow the
> variables you specified to stay in memory, and be accessible to all
> other applications.
>
> http://www.danga.com/memcached/
>
> Keep in mind though, just because ASP does it in one way, you don't want
> to do a bit for bit copy. You could also look into options like the
> auto_prepend feature in php.ini, and the define() function.
>
> http://us2.php.net/define
>
> I personally don't like using the auto_prepend feature, but it's there
> and you could use it if you like, I'm a fan of implicitly requiring
> files if I need to.
>
> If your associative array, is really that large that it's going to slow
> things down, you may also want to consider whether all your scripts need
> all of the data, and then possibly define things that are only necessary
> for certain classes, in the file for that class.
>
> You can also serialize your associative array, and store it in the
> database.. but it's really all dependant on what you need, and what the
> app needs.
>
>
>
> david wrote:
>> Hi
>>
>> I am looking at converting a large project from ASP to PHP, and have read
>> that there is no equivalent of global.asa in PHP. It is probably easiest
>> if
>> I describe the problem starting with how the ASP does it:
>>
>> Project uses global.asa to load a lot of 'global' constants and variables
>> into memory. This includes translations for the web site in a number of
>> different languages. These are loaded from text files so that changing
>> them
>> is easy. These items when loaded in global.asa are as if they are in an
>> associative array which is available to the whole application - it is not
>> destroyed when the page is destroyed!
>>
>> Any ideas how I could handle this in PHP? The ASP method seems sensible,
>> as
>> the data is much too big to load for every page, and too common to load
>> only
>> when required. Holding it in memory and it having application wide scope
>> like this is fast. Loading only parts required at execution from, say, a
>> database would surely be too costly in db calls?
>>
>> Anyone have any ideas about what I could do?
>>
>> Many thanks, David
>>
>>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 06h00.


Édité par : vBulletin® version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10828 seconds with 11 queries