To Do List Server Side

This example uses only two straightforward PHP programs. The first, readXMLFile.php, reads in an XML file; it is almost a copy of the code in Figure 16-16. If a HEAD request was sent, readXMLFile.php returns only the last-modified date of the file. If a GET request is sent, readXMLFile.php reads the requested file from the webserver and passes it to the browser. The only difference between Figure 16-16 and readXMLFile.php is that readXMLFile.php sends an additional header when responding to a GET request:

header("Content-Type: text/xml");

The second server-side program, saveXMLFile.php, saves an XML file. Figure 17-9 shows the PHP code. As I hope you'll see, it's very similar to the program we used to write out a text file ...

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.