PHP Require File statement is identical Include File statement (except upon failure it will also produce a fatal E_COMPILE_ERROR level error).
Also, their syntax relative and absolute file paths are identical.

PHP Require File Statement

require 'myfile.php';


PHP require file from parental directory (folder) - relative path

require(dirname(__DIR__).'/../ myfile.php');



PHP Require File from ROOT directory

require($_SERVER['DOCUMENT_ROOT']."/myfile.php");


PHP Require File deeper directory then ROOT - absolute path

$root = realpath($_SERVER["DOCUMENT_ROOT"]);
require "$root/folder1/folder2/myfile.php";









Privacy Policy