PHP require_once error when including file in parent folder PHP require_once error when including file in parent folder php php

PHP require_once error when including file in parent folder


I've googled and found this :require_once __DIR__.'/../inParent.php';


In my case I had to write:

require_once dirname( __FILE__ ) . '/' . '../../inParent.php';

And that worked!


This question is old, but for people like me who run across it, here is an answer from another part of Stack Overflow.

require_once($_SERVER['DOCUMENT_ROOT'] . '/inParent.php');

PHP require file from top directory