You are here: Re: Mantain a variable through several scripts like global.asa variables in asp « PHP Programming Language « IT news, forums, messages
Re: Mantain a variable through several scripts like global.asa variables in asp

Posted by Gordon Burditt on 12/28/05 06:34

>I have to port from asp a script that adds an ip to a list in plain
>text or an array. I need not using a database or filesystem, it has to
>be stored in memory in order that giving us best performance (it should
>be accessed continuously).

Have you actually MEASURED the performance to prove this?
Often, even program code isn't stored in memory most of the time.

If your web server gets restarted (software crash, someone trips
over power cable, maintenance), your variable goes poof! Is this
acceptable behavior?

>I've tried defining $_ENV vars, using apache_setenv(..), creating a
>class with a static var... but nothing results.

>In asp the script writes an reads an Application variable defined in
>global.asa... is it impossible to port? isn't it a very big error of
>php?

The closest PHP comes to this is one of:
- Sessions (does not apply to unrelated users)
- Files
- A database
- System V shared memory segments (shm_* functions)

Global variables are in general bad programming practice. Making
varibles that are "ultra-global" over all web page accesses by
unrelated users is asking for even more problems. How, for example,
do you prevent several simultaneous page accesses from simultaneously
updating (and screwing up) the variable? There's a reason why
databases have so many features relating to locking, transactions,
and consistent views of the data.

Gordon L. Burditt

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация