English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP getcwd() Function Usage and Example

PHP Directory Reference Manual

The getcwd() function gets the current working directory

Syntax

string getcwd(void);

Definition and Usage

It gets the current working directory.

Parameter

Serial NumberParameters and Description
1

void

No parameters required

Return value

Successfully returns the current working directory, returns FALSE on failure.

Online Example

The following is the usage of this function, getting the current working directory:

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

Output result:

/home/w3codebox
/home/w3codebox/html