PHP 5/MySQL Programming- P43

PHP 5/MySQL Programming- P43:computer programming has often been seen as a difficult and arcane skill. Programming languages are difficult and complicated, out of the typical person’s reach. However, the advent of the World Wide Web has changed that to some extent. It’s reasonably easy to build and post a Web page for the entire world to see. The language of the Web is reasonably simple, and numerous applications are available to assist in the preparation of static pages | 188 Examining File Access Modifiers PHP 5 MySQL Programming for the Absolute Beginner The final parameter in the fopen command is an access modifier. PHP supports a number of access modifiers which determine how your program interacts with the file. Files are usually opened for these modes reading writing or appending. Read mode opens a file for input so your program can read information from the file. You cannot write data to a file that is opened in read mode. Write mode allows you to open a file for output access. If the file does not exist PHP automatically creates it for you. Append mode allows you to write to a file without destroying the current contents. When you write to a file in append mode all new data is added to the end of the file. You can use a file for random access which allows a file to be open simultaneously for input and output but such files are often not needed in PHP. The relational database techniques provide the same capability with more flexibility and a lot less work. However the other forms of file access read write and output are extremely useful because they provide easy access to the file information. Table File Access Modifiers Modifier Type Description r Read-only Program can read from the file w Write Writes to the file overwriting it if it already exists a Append Writes to the end of the file r w Read and write Random access. Read or write to a specified part of the file Be very careful about opening a file in write mode. If you open an already existing file for write access PHP creates a new file and overwrites and destroys the old file s contents. In the Real World The r and w modifiers are used for another form of file access called random access which allows simultaneous reading and writing to the same file. While this is a very useful tool I won t spend a lot of time on it in this book. The sequential-access methods in this chapter are fine for simple file storage problems the XML and relational database functions in the

Không thể tạo bản xem trước, hãy bấm tải xuống
Đã 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.