PHP Includes folder, now working in sub folder

by 3 replies
5
Hi all,

I have a little question for programmers about PHP includes folder.

I am new to using PHP includes thingy, so what happened was; I setup my website using PHP includes folder and in that folder, I placed few banners and footer navigation files be called on every page.

But when I added a directory/folder on my domain, things started to get all messed up. The directory/folder I made is not fetching any footer and banners I have placed in the root includes folder. So I pasted the same includes folder in every new directory/folder I made for my site. But I am sure this is not the way it works.

Simple example of what I did:

- PHP includes placed on the root domain: www.mydomain.com - Things are working fine here and everything from the includes is showing on web pages.

- When I made a folder on my domain: www.mydomain.com/folder/ - HTML/PHP files in this new folder are not showing/fetching includes files.

Please tell me how this can be used professionally.

Also, is there any possibility that I can use a WEB URL in new folders to show includes folder data; like: "www.mydomain.com/includes/"
#programming #call #files #folder #includes #php #url #web #working
  • If you want pages in www.mydomain.com/folder to include files located in www.mydomain.com, then you have to reference them as ../includedfile.php for example.

    If you just put includedfile.php without the ../ it won't know the included file is really located in the root folder rather than the same folder as the page.
    • [1] reply

    • Thanks mate.

      So simply by placing two dots (../includes), I can tell the folder to get files from the root?
      • [1] reply

Next Topics on Trending Feed