linux灯需要文件

Not long ago I started using linux as OS principal. But I have a problem to include files. When I try include a file which in turn includes a third file, I end up getting a error: "failed to open stream: No such file or directory in /var/www/html/..."

For example, my files are distributed in this way:

enter image description here

and code of the 3 files is:

primero.php

require_once '../B/c/segundo.php';

segundo.php

require_once '../d/tercero.php';

tercero.php

echo 'success';

Error: Error

can someone explain to me what happens? this in windows works. and the truth is I would avoid using "dirname(FILE)"

PD: sorry, I can't post images

Using relative path, sometime is painful. Therefore what I start doing is creating a settings.inc.php file which I keep my important paths. For instance:

try this: settings.inc.php

<?php
define("ROOT_PATH" , dirname(__FILE__) . "/");
define("CLASS_PATH", ROOT_PATH . "class/");
?>

Then, I require the settings file in the header.php (so I can have it on every page)

require_once("settings.inc.php");

And I use it like

require_once(ROOT_PATH . 'B/c/segundo.php');

And

require_once(ROOT_PATH . 'd/tercero.php');

Using __DIR__ in front of require makes the required path relative to the file in which it is defined. For example:

  require_once __DIR__.'/../d/tercero.php';