1. Trang chủ
  2. » Công Nghệ Thông Tin

the book of javascript 2nd edition phần 8 ppsx

50 427 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 50
Dung lượng 570,14 KB

Nội dung

The \n puts a line break into the file, which creates a two-line file in this case If the write is successful, $success will contain the value TRUE; if not, it will contain the value FALSE Once you’ve written to a file, close it with fclose(): fclose($myFile); Combining these lines gives you the PHP script below: One of the more pernicious problems you’ll encounter when dealing with server-side programming is that of ensuring that your webserver has permission to alter the files you want to alter Sometimes a PHP program can fail to write to a file because the webserver running it does not have access to that particular file If this happens, PHP will give an error like this: Warning: fopen(yourFile.txt) [function fopen]: failed to open stream: Permission denied File permissions work differently on different operating systems If you get this kind of error, refer to your operating system’s manuals to determine how to inspect and modify file permissions Reading Files in PHP It’s a bit trickier to read a file using PHP than it is to write to a file The complication arises because the contents of a file are read line by line, and PHP needs to know when it has reached the end of a file so that it can stop reading Luckily, the PHP function feof() will tell PHP when it has reached the end of a file This function takes a variable that points to an open file (such as $myFile) and returns TRUE when the end of the file has been reached Figure 16-13 shows an example of PHP reading a file

Ngày đăng: 06/08/2014, 09:20

TỪ KHÓA LIÊN QUAN