skip to Main Content

Dears I´m having strange error on import files in PHP from another folders, I tryied dirname(__DIR__) and gives ‘Uncaught Error: not found in D:/project/’.

Than I tryied with define(‘LIB’,’D:project’), and it continues giving error on use.

What to do

my project have this tree:

project folders

Postman error

2

Answers


  1. You sould try this

    Use $_SERVER[‘DOCUMENT_ROOT’]

    $_SERVER[‘DOCUMENT_ROOT’] will point to the main folder.

    for example if the file is in project/fol/file.php project is the main folder, you can do it like this $root.’fol/file.php’

    Example You dir

    root/folder1/file.php <----- This file
     |  /folder2/folder3/file.php <----- Second file
     |  /folder4/folder/folder/YouHere.php <----- You include other part here !
    

    In PHP file

    $root = $_SERVER['DOCUMENT_ROOT'] . "/";
    require_once($root.'folder1/file.php');
    require_once($root.'folder2/folder3/file.php');
    
    Login or Signup to reply.
  2. I Solved it, the issue is in xampp configuration file, it had a grant Access Subfolders: FALSE

    I reinstall it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search