Jump to content

how to change current context?


saltzmanjoelh

Recommended Posts

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

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';

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.