Reading and writing global variables across scripts in PHP

前端 未结 9 1884
悲&欢浪女
悲&欢浪女 2020-12-11 21:56

Does PHP have global variables that can be modified by one running script and read by another?

9条回答
  •  执念已碎
    2020-12-11 22:12

    Global variables are bad in most programming. They're especially bad in multithreaded/multiuser systems like webapps. Avoid. If you must use global variables (rather than global constants) put them in a database with transactions guarding updates.

    Since you talk about different scripts though, it sounds like what you really want is a web application framework in a more application oriented language --- something like Django (python) or Rails (ruby). These let you think of your code much more like a cohesive PROGRAM, rather than a lot of loosely connected scripts that process web requests.

提交回复
热议问题