It returns parent directory’s path
Example
<?php
echo dirname(“/var/www”);
?>
Output
/var
It returns parent directory’s path
Example
<?php
echo dirname(“/var/www”);
?>
Output
/var
Check unlink() or unset()
It can be used to copy file
Example
<?php
copy(“test.txt”,”test.txt.new”) or die(“Failed to copy the file”);
?>
It can be used to clears file status cache
Example
<?php
clearstatcache();
?>
It can be used to change file ownership
Example
<?php
chown(“test.txt”, “phpcodez”);
?>
It can be used to change file permission
Example
<?php
chmod(“/var/www/test/”, 0777);
chmod(“/var/www/test/”, “u+rwx,go+rx”);
?>
It can be used to change file group
Example
<?php
$file = ‘test.txt’;
chgrp($file,”php”);
?>
It returns trailing name component of path
Example
<?php
echo basename(“/var/www/php”);
?>
Output
php
<?php
$fp = “test.txt”;
$number = count(file($fp));
echo ” $number lines “;
?>