Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Building a Web Application with PHP and MariaDB: A Reference Guide
  • Table Of Contents Toc
Building a Web Application with PHP and MariaDB: A Reference Guide

Building a Web Application with PHP and MariaDB: A Reference Guide

By : Sai S Sriparasa
4.3 (3)
close
close
Building a Web Application with PHP and MariaDB: A Reference Guide

Building a Web Application with PHP and MariaDB: A Reference Guide

4.3 (3)
By: Sai S Sriparasa

Overview of this book

This is a step-by-step, tutorial guide designed to help readers transition from beginners to more experienced developers using clear explanations. The variety of examples will help readers build, secure, and host real-time web applications. If you are a developer who wants to use PHP and MariaDB to build web applications, this book is ideal for you. Beginners can use this book to start with the basics and learn how to build and host web applications. Seasoned PHP Developers can use this book to get familiar with the new features of PHP 5.4 and 5.5, unit testing, caching, security, and performance optimization.
Table of Contents (12 chapters)
close
close
11
Index

Generating XML feeds


In the last section, we built our API to fetch the data and print the raw data onto the page. In this section, we will build methods that will take the data and convert them into XML feeds. A remote application can then use these XML feeds to ingest the data. Before we build the XML generation functionality, let's create a class variable that can be used to hold this XML data using the following code in the controllers/api.php file:

public $xml;

Now that we have added the class variable, let's add the following XML generation functionality to our API, present in the controllers/api.php file:

private function _generateXML($root, $data){
  $this->xml = new SimpleXMLElement("<$root/>");

  foreach($data as $key=>$value){
    $this->_generateXMLChild(substr($root, 0, -1), $value);
  }
  header("HTTP/1.1 200 OK");
  header("Content-Type: application/xml; charset=utf-8");
  echo $this->xml->asXML();
}

private function _generateXMLChild($type ,$item){

 ...
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Building a Web Application with PHP and MariaDB: A Reference Guide
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon