getcwd()
getcwd() — Gets the current working directory.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
Signature
getcwd(): string|false
Parameters
This function takes no parameters.
Return value
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.
Example
A runnable snippet:
// current directory echo getcwd() . "\n"; chdir('cvs'); // current directory echo getcwd() . "\n";
Output:
/home/didou /home/didou/cvs
See also
All PHP 8.5 built-in functions
Reference card built from the PHP manual page getcwd() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.