lime icon

Phosphorus and Lime

A Developer's Broadsheet

This blog has been deprecated. Please visit my new blog at klenwell.com/press.
PHP: parent directory
Question: what's the best method for dynamically obtaining a parent directory, e.g. the parent directory to the document root?

Answer: quite simple

// PARENT DIR: dirname(dirname($path_to_file))

# parent to current file
dirname(dirname(__FILE__))

# parent to document root (outside web tree)
dirname($_SERVER['DOCUMENT_ROOT'])


source: php.net