How do I include a file over 2 directories back?

Solution 1:

.. selects the parent directory from the current. Of course, this can be chained:

../../index.php

This would be two directories up.

Solution 2:

To include a file one directory back, use '../file'. For two directories back, use '../../file'. And so on.

Although, realistically you shouldn't be performing includes relative to the current directory. What if you wanted to move that file? All of the links would break. A way to ensure that you can still link to other files, while retaining those links if you move your file, is:

require_once($_SERVER['DOCUMENT_ROOT'] . 'directory/directory/file');

DOCUMENT_ROOT is a server variable that represents the base directory that your code is located within.

Solution 3:

. = current directory
.. = parent directory

So ../ gets you one directory back not two.

Chain ../ as many times as necessary to go up 2 or more levels.