PHP - Function getcwd()


Advertisements


Syntax

string getcwd ( void );

Definition and Usage

Gets the current working directory.

Parameters

Sr.No Parameter & Description
1

void

NA

Return Value

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

Example

Following is the usage of this function −

<?php
   // current directory
   echo getcwd() . "\n";
   
   getcwd('html');
   
   // current directory
   echo getcwd() . "\n";
?> 

This will produce the following result −

/home/tutorialspoint
/home/tutorialspoint/html

php_function_reference.htm