saltzmanjoelh Posted November 13, 2009 Share Posted November 13, 2009 I have this structure /public/gateway.php /public/controllers/SomeController.php /public/controllers/SomeOtherController.php /public/scripts/utilites.php While making the controllers, an include would look like include '../scripts/utilities.php'; but lets say I call my gateway.php script and that script creates an instance of my SomeController class. Now the context of the include is wrong. How do I change that context? It should be include 'scripts/utilites.php'; Link to comment https://forums.phpfreaks.com/topic/181426-how-to-change-current-context/ Share on other sites More sharing options...
MadTechie Posted November 13, 2009 Share Posted November 13, 2009 This dirname(__FILE__) will return the absolute path to the current file. so IN the controllers, you would have include dirname(__FILE__).'/../scripts/utilities.php'; and IN the gateway, you would have include dirname(__FILE__).'/scripts/utilities.php'; Link to comment https://forums.phpfreaks.com/topic/181426-how-to-change-current-context/#findComment-957068 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.