Jump to content

About the use of the __DIR__ controller.


LeonLatex
Go to solution Solved by requinix,

Recommended Posts

I'm putting together a script that includes the use of the controller __DIR__ In that regard, I'm wondering about a few things. Parts of the page are stored in a directory under the www directory. These are included and templates. I save the files in these folders because I want to make them not directly accessible via the browser. But now I see a problem that can occur since I use dir. Won't __DIR__ create a URL, which in turn will make the files inaccessible, that is, they will be perceived as trying to access the files via browser (hope you understand what I mean). Would it be better to use for example include alone? (for example, do not write include __DIR__ but only include)

Ang. __DIR__ then I wonder about another thing too: Does __DIR__ indicate the path from the root of the www directory (what some of the old trotters call the public directory), or is it from the directory in which the file in which the __DIR__ controller is used?

Link to comment
Share on other sites

  • Solution

__DIR__ is a "magic constant" (it's a constant with a value that varies) that is the directory of the file you put that code in. That's all there is to it. Period. Super simple. Nothing to do with URLs. Nothing to do with MVC design. Nothing to do with your website, really. Just a directory path.

  • Great Answer 1
Link to comment
Share on other sites

14 minutes ago, requinix said:

__DIR__ is a "magic constant" (it's a constant with a value that varies) that is the directory of the file you put that code in. That's all there is to it. Period. Super simple. Nothing to do with URLs. Nothing to do with MVC design. Nothing to do with your website, really. Just a directory path.

 

Thanks Requinix.

Link to comment
Share on other sites

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.