LeonLatex Posted April 13, 2023 Share Posted April 13, 2023 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? Quote Link to comment https://forums.phpfreaks.com/topic/316133-about-the-use-of-the-__dir__-controller/ Share on other sites More sharing options...
Solution requinix Posted April 13, 2023 Solution Share Posted April 13, 2023 __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. 1 Quote Link to comment https://forums.phpfreaks.com/topic/316133-about-the-use-of-the-__dir__-controller/#findComment-1607306 Share on other sites More sharing options...
LeonLatex Posted April 13, 2023 Author Share Posted April 13, 2023 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. Quote Link to comment https://forums.phpfreaks.com/topic/316133-about-the-use-of-the-__dir__-controller/#findComment-1607309 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.