Category Archives: PHP-File and Folder Functions - Page 2

PHP-chmod()

The chmod() file system function in PHP changes the file or folder permissions on a target file path. This function takes two parameters, first the target path and the second is the mode you wish to change the permissions to.

Here is the example:

PHP- basename()

The basename() file system function in PHP will return the base name of the file or path you point it at. You can use this function with one parameter or two. The first parameter is the target file or path, and the second is the suffix. If the base name ends with a suffix you may choose to remove it using the second parameter.
Here is the Example:

$file = “myproject/filename.txt”;
// Using one parameter
$baseName = basename($file);
echo $baseName;

echo ”
“;
// Using two parameters, the second to cut the suffix
$baseName = basename($file, “.txt”);
echo $baseName;
?>
OUTPUT:
filename.txt
filename