1For PHP < 5.3 use:
2
3$upOne = realpath(dirname(__FILE__) . '/..');
4In PHP 5.3 to 5.6 use:
5
6$upOne = realpath(__DIR__ . '/..');
7In PHP >= 7.0 use:
8
9$upOne = dirname(__DIR__, 1);
1// One level up
2echo str_replace(realpath(dirname(__FILE__) . '/..'), '', realpath(dirname(__FILE__)));
3
4// Two levels etc.
5echo str_replace(realpath(dirname(__FILE__) . '/../..'), '', realpath(dirname(__FILE__)));
6