Để thêm nút, bạn có thể sử dụng thư viện jQuery hoặc tập lệnh JavaScript đơn giản như được hiển thị bên dưới:button you may use either jQuery libraries or simple Javascript script as shown below:
Liên kết hoặc nút HTML: link or button:
click event
Javascript:
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
Sử dụng PHP để xóa nội dung tệp. Ví dụ, bạn có thể sử dụng FSEEK [$ FP, 0]; hoặc ftruncate [tài nguyên $ file, int $ size] Như dưới đây:PHP to clear a file content. For instance you can use the fseek[$fp, 0]; or ftruncate [ resource $file , int $size ] as below:
Chuyển hướng PHP - Bạn có thể sử dụng tiêu đề [Chuỗi $ chuỗi [, bool $ thay thế = true [, int $ http_response_code]]]]PHP - you can use header [ string $string [, bool $replace = true [, int $http_response_code ]] ]
Tôi hy vọng nó sẽ giúp.
Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Xem thảo luận
Cải thiện bài viết
Lưu bài viết
ĐọcSyntax:
unlink[ $filename, $context ];
Bàn luậnProgram 1: This program uses unlink[] function to remove file from directory. Suppose there is a file named as “gfg.txt”
Để xóa một tệp bằng cách sử dụng PHP rất dễ dàng. Xóa một tệp có nghĩa là xóa hoàn toàn một tệp khỏi thư mục để tệp không còn tồn tại. PHP có hàm hủy liên kết [] cho phép xóa một tệp. Hàm Php Unlink [] có hai tham số $ FileName và $ bối cảnh. Cú pháp:
0
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
1
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
2$file_pointer
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
4
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
5
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
6
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
7$file_pointer
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
9
0
9Output:
gfg.txt has been deleted
1
2 This program uses unlink[] function to delete a file from folder after using some operation.
Để xóa một tệp bằng cách sử dụng PHP rất dễ dàng. Xóa một tệp có nghĩa là xóa hoàn toàn một tệp khỏi thư mục để tệp không còn tồn tại. PHP có hàm hủy liên kết [] cho phép xóa một tệp. Hàm Php Unlink [] có hai tham số $ FileName và $ bối cảnh. Cú pháp:
9$file_pointer
6unlink[ $filename, $context ];2
8unlink[ $filename, $context ];4
$file_pointer
unlink[ $filename, $context ];6
PHP
$file_pointer
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
0
0
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
1
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
2$file_pointer
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
4
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
5
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
6
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
7$file_pointer
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
9
0
9Output:
Warning: unlink[] expects parameter 1 to be a valid path, resource given in C:\xampp\htdocs\server.php on line 12 Resource id #3 cannot be deleted due to an error
1
2 If the file does not exist then it will display an
error.
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
5
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
6
var btn = document.getElementById['button'];
function goclear[] {
alert["Handler called. Page will redirect to clear.php"];
document.location.href = "clear.php";
};
7$file_pointer
7Trong PHP, chúng ta có thể xóa bất kỳ tệp nào bằng cách sử dụng hàm hủy liên kết []. Hàm bỏ liên kết [] chỉ chấp nhận một đối số: Tên tệp. Nó tương tự như hàm Unix C Unlink [].
Php Unlink [] tạo lỗi cấp E_Warning nếu tệp không bị xóa. Nó trả về đúng nếu tệp bị xóa thành công nếu không sai.
Cú pháp
$ fileName đại diện cho tên của tệp sẽ bị xóa. represents the name of the file to be deleted.
Ví dụ về tệp xóa PHP
Đầu ra
File deleted successfully
Nhận xét
- Gửi phản hồi của bạn đến [Email & NBSP; được bảo vệ]