Pro PHP Patterns, Frameworks, Testing and more phần 6

chẳng hạn như mô hình quan sát, kiểm đếm, chức năng trợ giúp cho việc xác định đối tượng, và chế biến iterator. Ngoài ra, nó cung cấp chức năng tiên tiến để tự động load các lớp học và giao diện. Chương này giới thiệu bạn đến thư viện này rất quan trọng, | CHAPTER 11 SPL FILE AND DIRECTORY HANDLING 165 array path path to file filename pathname path to file perms 33261 inode 886570 size 1131 owner 1002 group 1002 atime 1167067832 mtime 1167067771 ctime 1167067771 type file isWritable true isReadable true isExecutable true isFile true isDir false isLink false Using SPLFileInfo is pretty straightforward. Do be aware that if you do not provide a path and file name then the pathname and path properties will omit the path. The path value is the same as calling dirname on the construction parameter and the pathname value is just a copy of the input parameter. Note The perms mask can be decoded in standard bitwise manner. If you are unfamiliar with this you can review an example in the fileperms function documentation in the PHP manual at http fileperms. The SPLFileInfo class supports extension through its provision of two key methods setInfoClass This defaults to SPLFileInfo. If you extend the SPLFileInfo class you will want to set this value to the name of your extended class. setFileClass This defaults to an SPLFileObject class. If you extend this class you should set this value to ensure that your extended class is what is provided by consumers of SPLFileInfo. 166 CHAPTER 11 SPL FILE AND DIRECTORY HANDLING These two functions have an effect on how the getFileinfo getPathinfo and openFile methods operate. It may seem slightly unintuitive that SplFileinfo has a getFileinfo method however since Directoryiterator and SPLFileObject descend from SPLFileInfo this method provides a way to access information about a specific file in an iterator or downcast a file object into an info object. The openFile method will access the file and return an SPLFileinfo object which can be used to perform operations within a file as discussed in the File Object Operations section later in this chapter. Iteration of Directories Locating files and directories on disk used to be a somewhat tedious task .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
20    76    1    22-05-2024
237    80    3    22-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.