Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Các tài liệu PHP cho tiêu đề là http://www.php.net/manual/en/function.header.php (hãy nhớ, bạn chỉ có thể tìm kiếm cho 'tiêu đề' trong ứng dụng Đề xuất, và nó sẽ dẫn bạn đến trang trợ giúp ). | Server-Side Techniques with PHP and MySQL 6. Once you know the server gives back the right response you can test the whole solution by loading http local host ajax foundati ons php phptest.html Figure 3.2 AJAX with PHP What Just Happened When it comes to generating XML structures not only on the client side but on the server side as well you have to choose between creating the XML document using the DOM or by joining strings. Your PHP script phptest .php starts by setting the content output to text xml php set the output content type as xml header Content-Type text xml The PHP documentation for header is http www.php .net manual en functi on. header.php remember you can simply search for header in the Suggest application and it will direct you to the help page . While in JavaScript files we use double quotes for strings in PHP we will always try to use single quotes. They are processed faster they are more secure and they are less likely to cause programming errors. Learn more about PHP strings at http php.net types.string. You can find two useful articles on PHP strings at http www.sitepoint .com print quick-php-tips and http www.jeroenmulder.com weblog 2005 04 php_single_and_ double_quotes.php. The PHP DOM not very surprisingly looks a lot like the JavaScript DOM. It all begins by creating a DOM document object which in PHP is represented by the DOMDocument class create the new XML document dom new DOMDocument Then you continue by creating the XML structure using methods such as createElement createTextNode appendchi ld and so on 70 Chapter 3 create the root response element response dom- createElement response dom- appendChild response create the books element and append it as a child of response books dom- createElement books response- appendChild books In the end we save the whole XML structure as a string using the saveXML function and echo the string to the output. xmlString dom- saveXML output the XML string echo xmlString The XML document is then read and