Hàm chmod() trong PHP - PHP Function
Code // chủ file được quyền đọc và viết, mọi người khác không có quyền. chmod("/somedir/somefile", 0600); // chủ file được quyền đọc và viết, mọi người khác có quyền đọc. chmod("/somedir/somefile", 0644); // chủ file có mọi quyền, mọi người có quyền đọc và thực ...
Hàm chown() trong PHP - PHP Function
Code // File name and username to use $file_name= "foo.php"; $path = "/home/sites/php.net/public_html/sandbox/" . $file_name ; $user_name = "root"; // Set the user chown($path, $user_name); // Check the result $stat = stat($path); print_r(posix_getpwuid($stat['uid'])
Hàm clearstatcache() trong PHP - PHP Function
Code $file = 'output_log.txt'; function get_owner($file) { $stat = stat($file); $user = posix_getpwuid($stat['uid']); return $user['name']; } $format = "UID @ %s: %s "; printf($format, date('r'), get_owner($file)); chown($file, 'ross'); printf($fo ...
Hàm copy() trong PHP - PHP Function
Code $file = 'test.txt'; $newfile = 'example.txt'; copy($file, $newfile);
Hàm unlink() trong PHP - PHP Function
Code file_put_contents("test.txt", "this is a test"); unlink("test.txt");
Hàm dirname() trong PHP - PHP Function
Code echo dirname('C:xampphtdocsLMGOpublic est.txt')."<br />"; echo dirname('/xampp/')."<br />"; echo dirname('.')."<br />";
Hàm disk_free_space() trong PHP - PHP Function
Code echo $df = disk_free_space("C:/xampphtdocs") . "<br />"; echo $df_c = disk_free_space("C:") . "<br />"; echo $df_d = disk_free_space("D:") . "<br />";
Hàm disk_total_space() trong PHP - PHP Function
Code echo $df = disk_total_space("C:/xampphtdocs") . "<br />"; echo $df_c = disk_total_space("C:") . "<br />"; echo $df_d = disk_total_space("D:") . "<br />";
Hàm diskfreespace() trong PHP - PHP Function
Code echo $df = diskfreespace("C:/xampphtdocs") . "<br />"; echo $df_c = diskfreespace("C:") . "<br />"; echo $df_d = diskfreespace("D:") . "<br />";
Hàm fclose() trong PHP - PHP Function
Code $handle = fopen('test.txt', 'r'); fclose($handle);
Hàm feof() trong PHP - PHP Function
Code file_put_contents('test.txt', 'Zaidap.com.net'); $fp = fopen('test.txt','rb'); while(feof($fp) == false) { $c = fgetc($fp); echo "kí tự thứ " .ftell($fp). " là: " . $c ."<br />"; }
Hàm fgetc() trong PHP - PHP Function
Code file_put_contents('test.txt', 'Zaidap.com.net'); $fp = fopen('test.txt','rb'); while(feof($fp) == false) { $c = fgetc($fp); echo $c ."<br />"; }
Hàm fgets() trong PHP - PHP Function
Code file_put_contents('test.txt', 'Zaidap.com.net <br /> this is a test'); $handle = @fopen("test.txt", "r"); if ($handle) { while (($buffer = fgets($handle, 2048)) !== false) { echo $buffer . "<br />"; } fclose($handle); }
Hàm fgetss() trong PHP - PHP Function
Code file_put_contents('test.txt', 'Zaidap.com.net <br /> this is a test'); $handle = @fopen("test.txt", "r"); if ($handle) { while (($buffer = fgets($handle, 2048)) !== false) { echo $buffer . "<br />"; } fclose($handle); }
Hàm file_exists() trong PHP - PHP Function
Code file_put_contents('test.txt', 'this is a test'); if (file_exists('test.txt')) { echo "file tồn tại!"; }else{ echo "file không tồn tồn tại!"; }
Hàm file_get_contents() trong PHP - PHP Function
Code file_put_contents('test.txt', 'this is a test'); //đọc toàn bộ file echo file_get_contents('test.txt'). "<br />"; //đọc từ vị trí số 5 và lây 4 kí tự echo file_get_contents('test.txt', null, null, 5, 4). "<br />"; //đọc từ cuối file và lây 4 kí tự echo ...
Hàm file_put_contents() trong PHP - PHP Function
Code file_put_contents('test.txt', 'this is a test'); //đọc toàn bộ file echo file_get_contents('test.txt');
Hàm file() trong PHP - PHP Function
Code $filename = 'index.php'; file_put_contents('test.txt', "This is a test. this is a example example. this is a newline." ); //đọc toàn bộ file $file = file('test.txt'); echo "<pre>"; print_r($file ); echo "</pre>";
Hàm fileatime() trong PHP - PHP Function
Code file_put_contents('test.txt', 'this is something'); if (file_exists('test.txt')){ echo "test.txt được truy cập cuối cùng vào lúc: " . date("F d Y H:i:s.", fileatime("test.txt")); }
Hàm filectime() trong PHP - PHP Function
Code $filename = 'test.txt'; if (file_exists($filename)) { echo "$filename được thay đổi lần cuối vào lúc: " . date("F d Y H:i:s.", filectime($filename)); }







