Directory Folder Path

using getcwd() – gets the current working directory – php function

echo getcwd();

using dirname() php function

echo dirname(__FILE__);
echo dirname($_SERVER[PHP_SELF]);

using basename() php function  – (PHP5+)

echo basename(__DIR__)

so if you want to use a file with require_once, include or require, the usage syntax can be the following:

require_once dirname(__FILE__) . '/folder/script.php';

Tags: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *