Pages

Friday, 6 March 2015

Glob & Unlink Di PHP

1.Unlink
Fungsi unlink() digunakan untuk menghapus file secara permanen. Nilai balik fungsi ini adalah TRUE jika proses hapus suskes dilakukan, dan FALSE jika prose penghapusan file gagal dilaksanakan.
Sintaksnya adalah (string filename)
Argumen string filename menyatakan nama file yang akan dihapus. Contoh aplikasi fungsi unlink() adalah:
<?PHP
$result=unlink(“data5.txt”);
if($result){
echo “File data5.txt telah berhasil dihapus”;
}else{
echo “FIle data5.txt gagal dihapus”;
}
?>

2.Glob
globFind pathnames matching a pattern

Description

array glob ( string $pattern [, int $flags = 0 ] )
The glob() function searches for all the pathnames matching pattern according to the rules used by the libc glob() function, which is similar to the rules used by common shells.

Parameters

pattern
The pattern. No tilde expansion or parameter substitution is done.
flags
Valid flags:
  • GLOB_MARK - Adds a slash to each directory returned
  • GLOB_NOSORT - Return files as they appear in the directory (no sorting). When this flag is not used, the pathnames are sorted alphabetically
  • GLOB_NOCHECK - Return the search pattern if no files matching it were found
  • GLOB_NOESCAPE - Backslashes do not quote metacharacters
  • GLOB_BRACE - Expands {a,b,c} to match 'a', 'b', or 'c'
  • GLOB_ONLYDIR - Return only directory entries which match the pattern
  • GLOB_ERR - Stop on read errors (like unreadable directories), by default errors are ignored.


0 comments:

Post a Comment