PHP | getcwd( ) Function Last Updated : 11 Jul, 2018 Comments Improve Suggest changes Like Article Like Report 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. Syntax: getcwd() 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: Program 1: php <?php //current directory $cur_dir = getcwd(); // displaying current directory echo $cur_dir ; ?> Output: user/home/gfg Program 2: php <?php //current directory $cur_dir = getcwd(); echo("Current Directory is " . $cur_dir); echo "<br>" ; //changing current directory $flag = chdir("user/home/articles"); if($flag == true) { $cur_dir = getcwd(); echo("Directory Has Been Successfully Changed to " . $cur_dir); } else { echo("Failed to Change Directory."); } ?> Output: Current Directory Location is user/home/gfg Directory Has Been Successfully Changed to user/home/articles Reference: http://php.net/manual/en/function.getcwd.php Comment More infoAdvertise with us Next Article PHP | getcwd( ) Function S Shubrodeep Banerjee Follow Improve Article Tags : Misc Web Technologies PHP PHP-file-handling PHP-function +1 More Practice Tags : Misc Similar Reads PHP posix_getpwuid() Function The posix_getpwuid() function is an inbuilt function in PHP that returns data related to a user using its user-id. This function returns an array with user information. Syntax: posix_getpwuid(int $user_id): array|falseParameter: This function accepts a single parameter: user_id: This parameter speci 1 min read PHP | opendir() Function The opendir() function in PHP is an inbuilt function which is used to open a directory handle. The path of the directory to be opened is sent as a parameter to the opendir() function and it returns a directory handle resource on success, or FALSE on failure. The opendir() function is used to open up 2 min read PHP | lstat( ) function The lstat() function in PHP is used to return information about a file or a symbolic link. It gathers statistics of the file which is sent as a parameter to the lstat() function. The function returns an array which includes information on following elements :  [0] or [dev] - Device number[1] or [in 4 min read PHP | gethostname() Function The gethostname() function is an inbuilt function in PHP which returns the host or domain name for the local machine. This function is applicable after PHP 5.3.0 before that there was another function called php_uname function. Syntax: string gethostname( void ) Parameters: This function doesn't acc 1 min read PHP password_get_info() Function The password_get_info() is an inbuilt PHP function where detailed information regarding the given hash will be returned. Syntax: password_get_info(string $hash): arrayParameter: This function accepts a single parameter: hash: This parameter defines the hash of the password by creating the password_h 1 min read PHP | link( ) Function The link() creates a hard link for a specified target. The target and the link are passed as parameters to the link() function and it returns true on success and false on failure.Syntax: link(target, link)  Parameters Used: The link() function in PHP accepts two parameters. target : It is a manda 2 min read PHP | pathinfo( ) Function The pathinfo() is an inbuilt function which is used to return information about a path using an associative array or a string. The returned array or string contains the following information:  Directory nameBasenameExtension The path and options are sent as a parameters to the pathinfo() function a 2 min read PHP | dir() Function The dir() function in PHP is an inbuilt function which is used to return an instance of the Directory class. The dir() function is used to read a directory, which includes the following: The given directory is opened. The two properties handle and path of dir() are available. Both handle and path pr 2 min read PHP | ftp_nlist() function The ftp_nlist() function is an inbuilt function in PHP which is used to get the list of all the filename and sub-directory in a specific directory on FTP server. Syntax: ftp_nlist( $ftp_connection, $directory ); Parameters: This function accepts two parameters as mentioned above and described below 3 min read Like