This article is mainly introduced in php tutorial directory operations functions is_dir, rd_dir, mkdir and other commonly used directory operation function examples. * / function dir_writeable ($ dir) / / Custom function extensions to create a writable directory { if (! is_dir ($ dir)) // if the given parameter is not a directory { @mkdir ($ dir, 0777); // Create a directory echo "directory." $ dir. "build success!" } } dir_writeable ("test"); // call a custom function to create the test directory / * Executing this code will create a directory named: test in the current directory and output at the same time: The directory test is successfully established * /
$ dir = "test"; // define the directory if (rmdir ($ dir)) // if the directory was deleted successfully { echo "directory." $ dir. "was successfully deleted!"; // output content } else { echo "Delete directory." $ dir. "An error occurred!"; }
function dir_writeable ($ dir) // Create a custom function extension { if (! is_dir ($ dir)) // if the given parameter is not a directory { @mkdir ($ dir, 0777); // Create a directory } if (is_dir ($ dir)) { if ($ fp = @ fopen ("$ dir / test.txt", 'w')) // Open the file under the specified path write, if not exist { @fclose ($ fp); // Close the file handle @unlink ("$ dir / test.txt"); // Delete the file $ writeable = 1; // define the return value is true } else { $ writeable = 0; // Define the return value is false } } return $ writeable; / / return value } // custom function end
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.