The getcwd() function in PHP is an inbuilt function which is used to return the current working directory. This function does not accepts any parameter and returns the current working directory on successful function call or FALSE on failure.
Parameters: This function does not accept any parameter.
Return Value: It returns the current working directory on successful function call or FALSE on failure.
Errors And Exceptions:
- getcwd() returns FALSE on some Unix variants if any one of the parent directories does not have the readable or search mode set.
- If you try to use getcwd() in a directory that is a symbolic link, getcwd() gives you the target of that link.
Below programs illustrate the getcwd() function:
Current Directory Location is user/home/gfg Directory Has Been Successfully Changed to user/home/articles