dom006.phpt

来自「PHP v6.0 For Linux 运行环境:Win9X/ WinME/ Wi」· PHPT 代码 · 共 41 行

PHPT
41
字号
--TEST--Test 6: Extends Test--SKIPIF--<?php  require_once('skipif.inc'); ?>--FILE--<?phpClass books extends domDocument {    function addBook($title, $author) {        $titleElement = $this->createElement("title");        $titleElement->appendChild($this->createTextNode($title));        $authorElement = $this->createElement("author");        $authorElement->appendChild($this->createTextNode($author));        $bookElement = $this->createElement("book");        $bookElement->appendChild($titleElement);        $bookElement->appendChild($authorElement);        $this->documentElement->appendChild($bookElement);    }   }$dom = new books;$dom->load(dirname(__FILE__)."/book.xml");$dom->addBook("PHP de Luxe", "Richard Samar, Christian Stocker");print $dom->saveXML();--EXPECT--<?xml version="1.0"?><books> <book>  <title>The Grapes of Wrath</title>  <author>John Steinbeck</author> </book> <book>  <title>The Pearl</title>  <author>John Steinbeck</author> </book><book><title>PHP de Luxe</title><author>Richard Samar, Christian Stocker</author></book></books>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?