Please wait while we load your page...


Latest Version [8.00202205221] Last Updated [May-22-2022]


PHP Manual [getcwd]

Protect Your Website Today

PHP Manual || Directory Functions

(PHP 4, PHP 5, PHP 7)

getcwdGets the current working directory


getcwd ( void ) : string

Gets the current working directory.

Return Values

Returns the current working directory on success, or FALSE on failure.

On some Unix variants, getcwd() will return FALSE if any one of the parent directories does not have the readable or search mode set, even if the current directory does. See chmod() for more information on modes and permissions.


If the PHP interpreter has been built with ZTS (Zend Thread Safety) enabled, the current working directory returned by getcwd() may be different from that returned by operating system interfaces. External libraries (invoked through FFI) which depend on the current working directory will be affected.


Example #1 getcwd() example


// current directory
echo getcwd() . "\n";


// current directory
echo getcwd() . "\n";


The above example will output something similar to:


See Also

PHP Manual || Directory Functions