9 HTML 5 Advanced PHP XML files PHP

  • Slides: 11
Download presentation
Μάθημα 9 Λίγο απ’ όλα! HTML 5 Advanced PHP XML files

Μάθημα 9 Λίγο απ’ όλα! HTML 5 Advanced PHP XML files

PHP XML offer. xml <? xml version="1. 0" encoding="UTF-8"? > <offer> < header>50% Discount

PHP XML offer. xml <? xml version="1. 0" encoding="UTF-8"? > <offer> < header>50% Discount on rooms</header> <body> Today all rooms 50% down</body> < /offer> <? php $xml=simplexml_load_file("note. xml") or die("Error: Cannot create object"); echo $xml->header. " "; echo $xml->body; ? >

PHP XML-DOM offer. xml <? xml version="1. 0" encoding="UTF-8"? > <offer> < header>50% Discount

PHP XML-DOM offer. xml <? xml version="1. 0" encoding="UTF-8"? > <offer> < header>50% Discount on rooms</header> <body> Today all rooms 50% down</body> < /offer> <? php $xml. Doc = new DOMDocument(); $xml. Doc->load(“offer. xml"); print $xml. Doc->save. XML(); ? > https: //www. php. net/manual/en/book. simplexml. php

PHP XML DOM offer. xml <? xml version="1. 0" encoding="UTF-8"? > <offer> < header>50%

PHP XML DOM offer. xml <? xml version="1. 0" encoding="UTF-8"? > <offer> < header>50% Discount on rooms</header> <body> Today all rooms 50% down</body> < /offer> <? php $xml. Doc = new DOMDocument(); $xml. Doc->load(“offer. xml"); $x = $xml. Doc->document. Element; foreach ($x->child. Nodes AS $item) { print $item->node. Name. " = ". $item-> node. Value. " "; } ? >

Συντακτικό Object {} {string : value} array [] [value] Value τύπου String, number, object,

Συντακτικό Object {} {string : value} array [] [value] Value τύπου String, number, object, array, true/false, null

JSON + PHP <? php $my. Obj = new Std. Class; $my. Obj->name =

JSON + PHP <? php $my. Obj = new Std. Class; $my. Obj->name = "John"; $my. Obj->age = 30; $my. Obj->city = "New York"; <? php $my. Arr = array(“name” => "John”, “age” => 30, “city” => "New York”); $my. JSON = json_encode($my. Arr); $my. JSON = json_encode($my. Obj); echo $my. JSON; ? > Η PHP έχει τη συνάρτηση json_encode για να μετατρέπει οποιοδήποτε αντικείμενο σε συντακτικό JSON