These functions manipulate or return information about files. Many of them are wrappers
for the commands you execute in a UNIX or Windows command shell.
When the functions in this section call for a filename or a directory, you may name a file
in the same directory as the script itself. You may also use a full or relative path. The.
and .. directories are valid in both UNIX and Windows. You may also specify drive
letters on a Windows machine. Backslashes can delimit directories and filenames when
running under Windows, but forward slashes are interpreted correctly, so you stick with
them.
boolean chdir(string directory)
When a PHP script begins to execute, its default path is the path to the script itself. That
is, if the fully qualified path to the script were /users/leon/
public_html/somescript.php, then all relative paths would work off
/users/leon/public_html/. You may change this default path with the chdir
function. It returns TRUE if the change was made, FALSE if the script was unable to change
directories.
<?
if(chdir("/tmp"))
{
print("current directory is /tmp");
}
else
{
print("unable to change to /tmp");
}
?>
boolean chgrp(string filename, string group)
The chgrp function invokes the UNIX idea of changing the group to which a file
belongs. If successful, TRUE is returned. If the group cannot be changed, FALSE is
returned. Under Windows this function always returns TRUE and leaves the file
unchanged. Two similar functions are chmod and chown. If you want to find the group to
which a file is currently assigned, use the filegroup function.
You may wish to refer to the UNIX man page for the shell command of the same name.
<?
if(chgrp("log.txt", "editors"))
{
print("log.txt changed to editors group");
}
else