The situation is as follows: such code

include("/../../block.php"); 

Writing there is no file. I wrote differently:

 include("../../block.php"); 

File not found anyway. Decided otherwise:

 include(__DIR\__."/../../block.php"); 

Bingo! Raboat! So why did this happen? It seems that the options are identical. What is the problem?

    3 answers 3

    include ("/../../ block.php");

    You have specified a path relative to the root directory.

    include ("../../ block.php");

    This, in theory, should work, but the configuration of your server does not allow, for this, use the design

     include("./../../block.php"); 

    And it will be easier for everyone ./ - current directory (in which your file is)

    • Unfortunately, it does not work, it seems that the possibility of such a record is disabled in general, which piece in the config will enable it? - iproger

    __DIR__ - File Directory. If used inside a include file, the directory of this file is returned. This is equivalent to calling dirname ( FILE ). The returned directory name does not end in a slash, except for the root directory (added in PHP 5.3.0.)

    those. it does not denote the current directory. When you click on relative links, you are connected to the set directory (which may differ from the file directory)

      In general, there is a good thing $_SERVER['DOCUMENT_ROOT']