PHP how to go one level up on dirname(__FILE__)

You can use dirname(dirname(__FILE__)) to go one level up in the directory structure when using __FILE__ (which returns the current file's path). For example:

<?php

$current_file_path = __FILE__;
$one_level_up = dirname($current_file_path);
$two_levels_up = dirname($one_level_up);

Watch a course Learn object oriented PHP

You can also use the .. notation to go one level up as well

$two_levels_up = dirname(__FILE__) . '/..';