PHP AdvancedLesson 32Free preview
PHP File Handling
This lesson is part of PHP · All levels
Summary
PHP can work with files on servers, from checking for existence, reading, writing, to deleting them. This lesson introduces the basic file handling functions and opening modes such as r, w, and a. File path security is essential to preventing attacks on applications.
Key points
- Check if a file exists
- Mode r to read, w to write/write, a to add at the end
- Always close the file that is opened with fclose()
- Validate the file path so that users cannot access any location
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.