Home » PHP

PHP chdir() function with example

PHP chdir() function: Here, we are going to learn about the PHP chdir() function with its syntax, parameters, returns type, and example.
Submitted by IncludeHelp, on August 11, 2019

PHP chdir() function

The full form of chdir is "Change Directory", the function chdir() is used to change the current working directory.

Syntax:

    mkdir(directory);

Parameter(s):

  • directory – It defines the new directory.

Return value:

It returns a Boolean value, "TRUE" – if directory changes successfully or "FALSE" – if the directory does not change.

Example: PHP code to change the directory

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

//changing the directory
chdir("/home/folder1");

//after changing the directory....
//getting & printing current working directory
$result = getcwd();
echo "current working directory is: ".$result."<br/>";
?>

Output

current working directory is: /home
current working directory is: /home/folder1






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.