Provides various official and user-released code examples and code reference. You are welcome to exchange and learn simple online file system management.
File traversal. I haven't finished writing it yet.
OnlineEditor. php file code
// Online file editor /*------------------------------------- Implemented using the factory design pattern and MVC */
Class onlineEditor {
// Set the global variable path Public $ filePath = null; // Set the filtering information Private $ fileFilter = array ( 'Onlineeditor. php ', 'ViewEditor.html ', 'Index. php ', '.', '..' );
// The constructor must be private in the singleton design mode. Function _ construct ($ filePath ){ $ This-> filePath = $ filePath; }
// Operations performed when the class is destroyed Function _ destruct (){ // Echo $ this-> filePath; }
// Obtain the object content Function getContent ($ filePath ){ If (! Isset ($ filePath )){
// Put the file content Function putContent ($ filePath, $ fileContent ){ File_put_contents ($ filePath, $ fileContent ); }
// Determine whether the directory exists Private function judgeExist (){ // Determine whether the directory is empty or no file If (is_dir ($ this-> filePath) & file_exists ($ this-> filePath )){ Return true; } Else { Return false; } }
// Create a file Function createFile ($ filename ){ If (! File_exists ($ filename )){ Fopen ($ filename, "w + "); }
Else { Echo "Click here to return "; Die ("the file already exists "); }
} // Delete an object Function delFile ($ filename ){ If (file_exists ($ filename )){ Unlink ($ filename ); } }
// Main Function Function main (){ If ($ this-> judgeExist ()){ // Obtain the object that opens the folder $ FileOpen = opendir ($ this-> filePath ); $ FileMes = array (); $ I = 0; // Traverse folders While ($ file = readdir ($ fileOpen )){
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.