简体   繁体   中英

How to set/read PHP variables from web.config?

I have many PHP scripts which uses the same variables (eg server names, urls, ...etc).

I currently have these variables in a single php file which is referenced by other scripts (ex: require 'Variables.php').

This work fine for the moment, but it's not very flexible. I need a way to change these variables based on my build (debug, release...etc).

I am trying to read my configuration settings from the web.config and somehow allow PHP to use them.

How can this be done?

I've already tried this, but it doesnt seem to work. Setting php.ini variables inside web.config on IIS 7.5

* Resolved *

I was able to find a nice solution. I basically have multiple versions of a init.php file (debug, release...etc under respectively named folders). The correct init.php (based on the build mode) is then copied to the destination location as a post-build copy operation.

I was able to find a nice solution. I basically have multiple versions of a init.php file (debug, release...etc under respectively named folders). The correct init.php (based on the build mode) is then copied to the destination location as a post-build copy operation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM