Jump to content

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

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.