Hàm rename () trong PHP
❮ Tham chiếu hệ thống tệp PHPThí dụ
Đổi tên thư mục + tệp:
<?php
rename("images","pictures");
rename("/test/file1.txt","/home/docs/my_file.txt");
?>
Định nghĩa và Cách sử dụng
Hàm rename () đổi tên một tệp hoặc thư mục.
Cú pháp
rename(old, new, context)
Giá trị tham số
Parameter | Description |
---|---|
old | Required. Specifies the file or directory to be renamed |
new | Required. Specifies the new name for the file or directory |
context | Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream |
Chi tiết kỹ thuật
Giá trị trả lại: | ĐÚNG về thành công, SAI về thất bại |
---|---|
Phiên bản PHP: | 4.0+ |
PHP Changelog: | PHP 5.3.1: Cho phép đổi tên tệp trên các ổ đĩa trong Windows. PHP 5.0: Có thể được sử dụng với một số trình bao bọc URL. |
❮ Tham chiếu hệ thống tệp PHP