Good time, I have problems - I can’t connect a single script to a page through the include function, for example, the required file (rmk.php) is relative to the root in the scrips folder, and the file in which we are connecting is relative to the root - maun / nex / page.php

I'm trying to connect it like this include ("... / scrips / rmk.php"); There is no effect, despite the fact that if you connect the same file to the page maun / example.php like this include ("../ scrips / rmk.php"); then everything comes on hurray! is there some other method needed ??? since then include ("./../ scrips / rmk.php"); ? Tell me please!

  • so just want the relative ways to use \ - dantelol
  • you create define('MAIN_ROOT', __DIR__) in your main file, which lies in the root, and wherever you specify the paths you add include MAIN_ROOT. 'root / fileName.php' - Vasily Barbashev

1 answer 1

You can connect the file as follows, first going up two levels, and then going down to the scripts folder

 include("../../scrips/rmk.php"); 

However, it is better to use the environment variable DOCUMENT_ROOT, which tells the absolute path to the root of your site.

 include($_SERVER['DOCUMENT_ROOT'] . "/scrips/rmk.php");