PHP Directory getcwd() Function (With Examples)

In this tutorial, we will learn about the PHP getcwd() function with its usage, syntax, parameters, return value, and examples. By IncludeHelp Last updated : December 31, 2023

PHP getcwd() function

The full form of getcwd is "Get Current Working Directory", the function getcwd() is used to get the name of the current working directory, it does not accept any parameter and returns the current working directory.

Syntax

The syntax of the getcwd() function:

getcwd();

Parameters

The parameters of the getcwd() function:

  • It does not accept any parameter.

Return Value

If function execution is the success, it returns the current working directory and it returns "FALSE" if function execution is failed.

PHP getcwd() Function Example

PHP code to get the name of the current working directory.

<?php
$result = getcwd();
echo "current working directory is: ".$result."<br/>";
?>

Output

The output of the above example is:

current working directory is: /home

To understand the above example, you should have the basic knowledge of the following PHP topics:

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.