0

Cannot include file from the file located in the same parent directory.

This is the file structure

 - ROOT   
     -> source_code
        -> functions
            -> FileFunction.php
        -> template
            -> WebContent.php

I want to include FileFunction.php in the WebContent.php file but, it gives me a warning says cannot find a file in the directory.

Here is what I write on the WebContent.php file

include("../functions/FileFunction.php");
user3505908
  • 5
  • 1
  • 7
  • How you are calling `WebContent.php` – Muhammad Hassaan Aug 04 '15 at 06:16
  • Try using: `include(__DIR__."/../functions/FileFunction.php");` – Rasclatt Aug 04 '15 at 06:16
  • Paths are resolved relative to the point of execution, which is not always where the include exists. If you want to construct an absolute path based on the directory that contains the file with the include use __DIR__ as in `include(__DIR__."/../functions/FileFunction.php");` – Orangepill Aug 04 '15 at 06:18
  • Calling WebContent.php from another file called index.php. I just started to realize that could be a problem. – user3505908 Aug 04 '15 at 06:28
  • One often runs into this error, and to quickly troubleshoot it, follow these steps : http://stackoverflow.com/a/36577021/2873507 – Vic Seedoubleyew Apr 12 '16 at 16:53

0 Answers0