fatkatie Posted September 8, 2017 Share Posted September 8, 2017 I run a php script in three main environments. Unique environment parameters/defs are defined in a file defs.php. This file must run first in any script. I'm trying to figure out how to find it. A php script can light up anywhere, so I have three ideas about how to do this. Input please. 1. Distribute the def.php as linked files in all the directories which contain php scripts that use it. In windows I think its a copy option only. This is small file so I'm not worried about casting it about. 2. Do an logic thing like: if ((include '/xampp/htdocs/news/defs.php') == false) { include '/home/networkHALTSTANK/public_html/news/defs.php'; } 3. Use the Apache server somehow to do this ... which I'll investigate if someone will please point the way. One of the Apache servers resides on a godaddy unix share so I don't have access to all the switches. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/304907-including-that-first-file-in-php/ Share on other sites More sharing options...
fatkatie Posted September 8, 2017 Author Share Posted September 8, 2017 Thought of a 4th option. Perhaps just do a require_once, 3 times; Quote Link to comment https://forums.phpfreaks.com/topic/304907-including-that-first-file-in-php/#findComment-1550944 Share on other sites More sharing options...
Solution archive Posted September 8, 2017 Solution Share Posted September 8, 2017 Use $_SERVER['DOCUMENT_ROOT'] ... defs.php and then add whatever path you are using to get to the defs.php file. Only have one version of the file, otherwise it will be a nightmare to keep up to date and pointless having it in the first place. 1 Quote Link to comment https://forums.phpfreaks.com/topic/304907-including-that-first-file-in-php/#findComment-1550987 Share on other sites More sharing options...
fatkatie Posted September 24, 2017 Author Share Posted September 24, 2017 Thanks. You've triggered another DOH!!! moment. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/304907-including-that-first-file-in-php/#findComment-1551853 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.