mirror of
https://github.com/php/doc-en.git
synced 2026-03-23 23:32:18 +01:00
Mark oop5 and xml* categories as 'interactive' (with exceptions) and use 'examples/' dir for XML example files so they (will) work with WASM
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<chapter xml:id="language.oop5" xmlns="http://docbook.org/ns/docbook">
|
||||
<chapter xml:id="language.oop5" xmlns="http://docbook.org/ns/docbook" annotations="interactive">
|
||||
<title>Classes and Objects</title>
|
||||
|
||||
<sect1 xml:id="oop5.intro">
|
||||
|
||||
@@ -194,8 +194,8 @@ class C extends A
|
||||
but must have either <literal>get</literal> or <literal>set</literal> declared but not defined (as in the example above).
|
||||
</simpara>
|
||||
<example>
|
||||
<title>Abstract property example</title>
|
||||
<programlisting role="php">
|
||||
<title>Abstract property with hooks example</title>
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
and <literal>MyClass2</literal> from the files <filename>MyClass1.php</filename>
|
||||
and <filename>MyClass2.php</filename> respectively.
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
spl_autoload_register(function ($class_name) {
|
||||
@@ -90,7 +90,7 @@ Fatal error: Interface 'ITest' not found in ...
|
||||
by Composer. By including this file, those packages can be used without
|
||||
any additional work.
|
||||
</simpara>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
@@ -807,7 +807,7 @@ NS\ClassName
|
||||
<para>
|
||||
<example>
|
||||
<title>Nullsafe Operator</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ class Point {
|
||||
</note>
|
||||
<example>
|
||||
<title>Using new in initializers</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<para>
|
||||
<example>
|
||||
<title>Property declarations</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class SimpleClass
|
||||
@@ -201,7 +201,7 @@ Fatal error: Uncaught Error: Typed property Shape::$numberOfSides must not be ac
|
||||
explicitly if desired.
|
||||
<example>
|
||||
<title>Example of readonly properties</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
@@ -241,7 +241,7 @@ $test->prop = "foobar";
|
||||
A readonly property can only be initialized once, and only from the scope where it has been declared. Any other assignment or modification of the property will result in an <classname>Error</classname> exception.
|
||||
<example>
|
||||
<title>Illegal initialization of readonly properties</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class Test1 {
|
||||
@@ -261,7 +261,7 @@ $test1->prop = "foobar";
|
||||
<para>
|
||||
Specifying an explicit default value on readonly properties is not allowed, because a readonly property with a default value is essentially the same as a constant, and thus not particularly useful.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
@@ -283,7 +283,7 @@ class Test {
|
||||
<para>
|
||||
Modifications are not necessarily plain assignments, all of the following will also result in an <classname>Error</classname> exception:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
@@ -312,7 +312,7 @@ foreach ($test as &$prop);
|
||||
<para>
|
||||
However, readonly properties do not preclude interior mutability. Objects (or resources) stored in readonly properties may still be modified internally:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ Hello World!
|
||||
to be able to use B's bigTalk implementation under an additional alias
|
||||
<literal>talk</literal>.
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
trait A {
|
||||
@@ -269,7 +269,7 @@ class Aliased_Talker {
|
||||
</para>
|
||||
<example xml:id="language.oop5.traits.visibility.ex1">
|
||||
<title>Changing Method Visibility</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
trait HelloWorld {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
</para>
|
||||
<example>
|
||||
<title>Property declaration</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/**
|
||||
@@ -88,7 +88,7 @@ $obj2->printHello(); // Shows Public2, Protected2, Undefined
|
||||
</simpara>
|
||||
<example>
|
||||
<title>Asymmetric Property visibility</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class Book
|
||||
@@ -182,7 +182,7 @@ $b->pubYear = 2023; // Fatal Error
|
||||
</simpara>
|
||||
<example>
|
||||
<title>Asymmetric Property inheritance</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class Book
|
||||
@@ -214,7 +214,7 @@ class SpecialBook extends Book
|
||||
</para>
|
||||
<example>
|
||||
<title>Method Declaration</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/**
|
||||
@@ -313,7 +313,7 @@ $myFoo->test(); // Bar::testPrivate
|
||||
</para>
|
||||
<example>
|
||||
<title>Constant Declaration as of PHP 7.1.0</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/**
|
||||
@@ -378,7 +378,7 @@ $myclass2->foo2(); // Public and Protected work, not Private
|
||||
</para>
|
||||
<example>
|
||||
<title>Accessing private members of the same object type</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class Test
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<book xml:id="book.dom" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<book xml:id="book.dom" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
|
||||
<?phpdoc extension-membership="bundledexternal" ?>
|
||||
<title>Document Object Model</title>
|
||||
<titleabbrev>DOM</titleabbrev>
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<?php
|
||||
|
||||
// We need to validate our document before referring to the id
|
||||
$doc = Dom\XMLDocument::createFromFile('book.xml', LIBXML_DTDVALID);
|
||||
$doc = Dom\XMLDocument::createFromFile('examples/book-docbook.xml', LIBXML_DTDVALID);
|
||||
|
||||
// We retrieve the attribute named id of the chapter element
|
||||
$attr = $doc->getElementsByTagName('chapter')->item(0)->getAttributeNode('id');
|
||||
|
||||
@@ -48,7 +48,7 @@ $doc = new DOMDocument;
|
||||
|
||||
// We need to validate our document before referring to the id
|
||||
$doc->validateOnParse = true;
|
||||
$doc->load('book.xml');
|
||||
$doc->load('examples/book-docbook.xml');
|
||||
|
||||
// We retrieve the attribute named id of the chapter element
|
||||
$attr = $doc->getElementsByTagName('chapter')->item(0)->getAttributeNode('id');
|
||||
|
||||
@@ -71,7 +71,7 @@ $doc2 = new DOMDocument;
|
||||
$doc2->loadXML("<root/>");
|
||||
$doc2->documentElement->appendChild($doc2->adoptNode($hello));
|
||||
|
||||
echo $doc1->saveXML() . PHP_EOL;
|
||||
echo $doc1->saveXML() . PHP_EOL . PHP_EOL;
|
||||
echo $doc2->saveXML();
|
||||
?>
|
||||
]]>
|
||||
|
||||
@@ -60,7 +60,7 @@ $doc = new DomDocument;
|
||||
|
||||
// We need to validate our document before referring to the id
|
||||
$doc->validateOnParse = true;
|
||||
$doc->Load('book.xml');
|
||||
$doc->load('examples/book.xml');
|
||||
|
||||
echo "The element whose id is 'php-basics' is: " . $doc->getElementById('php-basics')->tagName . "\n";
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument();
|
||||
$doc->load('book.xml');
|
||||
$doc->load('examples/book.xml');
|
||||
echo $doc->saveXML();
|
||||
?>
|
||||
]]>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
$dom = new DOMDocument;
|
||||
$dom->load('book.xml');
|
||||
$dom->load('examples/book.xml');
|
||||
if ($dom->validate()) {
|
||||
echo "This document is valid!\n";
|
||||
}
|
||||
@@ -58,7 +58,7 @@ if ($dom->validate()) {
|
||||
<?php
|
||||
$dom = new DOMDocument;
|
||||
$dom->validateOnParse = true;
|
||||
$dom->load('book.xml');
|
||||
$dom->load('examples/book.xml');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
@@ -57,7 +57,7 @@ $xml = <<<EOD
|
||||
<chapter xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<title>Books of the other guy..</title>
|
||||
<para>
|
||||
<xi:include href="book.xml">
|
||||
<xi:include href="examples/book.xml">
|
||||
<xi:fallback>
|
||||
<error>xinclude: book.xml not found</error>
|
||||
</xi:fallback>
|
||||
|
||||
@@ -46,12 +46,10 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('book.xml');
|
||||
|
||||
$id = $doc->firstChild->attributes->getNamedItem('id');
|
||||
$doc->load('examples/book.xml');
|
||||
|
||||
$id = $doc->firstChild->nextSibling->nextSibling->firstChild->nextSibling->attributes->getNamedItem('id');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -61,9 +59,11 @@ $id = $doc->firstChild->attributes->getNamedItem('id');
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('examples/book.xml');
|
||||
|
||||
$id = $doc->firstChild->attributes['id'];
|
||||
|
||||
$id = $doc->firstChild->nextSibling->nextSibling->firstChild->nextSibling->attributes['id'];
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
<?php
|
||||
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('book.xml');
|
||||
$doc->load('examples/book-docbook.xml');
|
||||
|
||||
$book = $doc->documentElement;
|
||||
|
||||
|
||||
@@ -56,16 +56,14 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('book.xml');
|
||||
$doc->load('examples/book-docbook.xml');
|
||||
|
||||
$items = $doc->getElementsByTagName('entry');
|
||||
|
||||
for ($i = 0; $i < $items->length; $i++) {
|
||||
echo $items->item($i)->nodeValue . "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -75,6 +73,10 @@ for ($i = 0; $i < $items->length; $i++) {
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('examples/book-docbook.xml');
|
||||
|
||||
$items = $doc->getElementsByTagName('entry');
|
||||
|
||||
for ($i = 0; $i < $items->length; $i++) {
|
||||
echo $items[$i]->nodeValue . "\n";
|
||||
@@ -89,11 +91,14 @@ for ($i = 0; $i < $items->length; $i++) {
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('examples/book-docbook.xml');
|
||||
|
||||
$items = $doc->getElementsByTagName('entry');
|
||||
|
||||
foreach ($items as $item) {
|
||||
echo $item->nodeValue . "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
|
||||
$doc = new DOMDocument;
|
||||
|
||||
$doc->load('book.xml');
|
||||
$doc->load('examples/book-dcobook.xml');
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ $doc = new DOMDocument;
|
||||
// We don't want to bother with white spaces
|
||||
$doc->preserveWhiteSpace = false;
|
||||
|
||||
$doc->load('book.xml');
|
||||
$doc->load('examples/book-docbook.xml');
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
|
||||
@@ -136,7 +136,7 @@ Found The Pearl, by John Steinbeck
|
||||
$doc = new DOMDocument;
|
||||
$doc->preserveWhiteSpace = false;
|
||||
|
||||
$doc->load('book.xml');
|
||||
$doc->load('examples/book-docbook.xml');
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('book.xml');
|
||||
$doc->load('examples/book-simple.xml');
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
|
||||
@@ -177,7 +177,7 @@ PHP Secrets by Jenny Smythe
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('book.xml');
|
||||
$doc->load('examples/book-simple.xml');
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
|
||||
@@ -218,7 +218,7 @@ PHP Basics
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument;
|
||||
$doc->load('book.xml');
|
||||
$doc->load('examples/book-simple.xml');
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<book xml:id="book.libxml" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<book xml:id="book.libxml" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
|
||||
<?phpdoc extension-membership="bundledexternal" ?>
|
||||
<title>libxml</title>
|
||||
|
||||
|
||||
@@ -80,10 +80,9 @@
|
||||
<para>
|
||||
<example>
|
||||
<title>A <function>libxml_set_streams_context</function> example</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$opts = array(
|
||||
'http' => array(
|
||||
'user_agent' => 'PHP libxml agent',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<book xml:id="book.mbstring" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<book xml:id="book.mbstring" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
|
||||
<?phpdoc extension-membership="bundled" ?>
|
||||
<title>Multibyte String</title>
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
<para>
|
||||
<example>
|
||||
<title><function>mb_convert_encoding</function> example</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/* Convert internal character encoding to SJIS */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<book xml:id="book.pcre" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<book xml:id="book.pcre" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
|
||||
<?phpdoc extension-membership="core" ?>
|
||||
<title>Regular Expressions (Perl-Compatible)</title>
|
||||
<titleabbrev>PCRE</titleabbrev>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<example>
|
||||
<title><function>preg_replace_callback</function> and
|
||||
anonymous function</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/* a unix-style command line filter to convert uppercase
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<book xml:id="book.simplexml" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<book xml:id="book.simplexml" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
|
||||
<?phpdoc extension-membership="bundledexternal" ?>
|
||||
<title>SimpleXML</title>
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Include file example.php with XML string</title>
|
||||
<title>Include file examples/simplexml-data.php with XML string</title>
|
||||
<programlisting role="php" xml:id="simplexml.examples.movie">
|
||||
<![CDATA[
|
||||
<?php
|
||||
@@ -59,7 +59,7 @@ XML;
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'example.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$movies = new SimpleXMLElement($xmlstr);
|
||||
|
||||
@@ -88,7 +88,7 @@ echo $movies->movie[0]->plot;
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'example.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$movies = new SimpleXMLElement($xmlstr);
|
||||
|
||||
@@ -114,7 +114,7 @@ PHP solves all my web problems
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'example.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$movies = new SimpleXMLElement($xmlstr);
|
||||
|
||||
@@ -154,7 +154,7 @@ Mr. Coder played by El ActÓr
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'example.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$movies = new SimpleXMLElement($xmlstr);
|
||||
|
||||
@@ -192,7 +192,7 @@ foreach ($movies->movie[0]->rating as $rating) {
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'example.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$movies = new SimpleXMLElement($xmlstr);
|
||||
|
||||
@@ -222,7 +222,7 @@ My favorite movie.PHP: Behind the Parser
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'example.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$movies1 = new SimpleXMLElement($xmlstr);
|
||||
$movies2 = new SimpleXMLElement($xmlstr);
|
||||
@@ -252,7 +252,7 @@ bool(false)
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'example.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$movies = new SimpleXMLElement($xmlstr);
|
||||
|
||||
@@ -281,7 +281,7 @@ Mr. Coder played by El ActÓr
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'example.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
$movies = new SimpleXMLElement($xmlstr);
|
||||
|
||||
$movies->movie[0]->characters->character[0]->name = 'Miss Coder';
|
||||
@@ -333,7 +333,7 @@ echo $movies->asXML();
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'example.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
$movies = new SimpleXMLElement($xmlstr);
|
||||
|
||||
$character = $movies->movie[0]->characters->addChild('character');
|
||||
|
||||
@@ -104,15 +104,15 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// The file test.xml contains an XML document with a root element
|
||||
// The file examples/book.xml contains an XML document with a root element
|
||||
// and at least an element /[root]/title.
|
||||
|
||||
if (file_exists('test.xml')) {
|
||||
$xml = simplexml_load_file('test.xml');
|
||||
if (file_exists('examples/book.xml')) {
|
||||
$xml = simplexml_load_file('examples/book.xml');
|
||||
|
||||
print_r($xml);
|
||||
} else {
|
||||
exit('Failed to open test.xml.');
|
||||
exit('Failed to open examples/book.xml.');
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
@@ -124,7 +124,7 @@ if (file_exists('test.xml')) {
|
||||
<![CDATA[
|
||||
SimpleXMLElement Object
|
||||
(
|
||||
[title] => Example Title
|
||||
[book] => Array
|
||||
...
|
||||
)
|
||||
]]>
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
<para>
|
||||
<note>
|
||||
<para>
|
||||
Listed examples may include <literal>example.php</literal>,
|
||||
Listed examples may include <literal>examples/simplexml-data.php</literal>,
|
||||
which refers to the XML string found in the first example
|
||||
of the <link linkend="simplexml.examples-basic">basic usage</link> guide.
|
||||
</para>
|
||||
@@ -75,7 +75,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
include 'example.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$sxe = new SimpleXMLElement($xmlstr);
|
||||
$sxe->addAttribute('type', 'documentary');
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
<para>
|
||||
<note>
|
||||
<para>
|
||||
Listed examples may include <literal>example.php</literal>,
|
||||
Listed examples may include <literal>examples/simplexml-data.php</literal>,
|
||||
which refers to the XML string found in the first example
|
||||
of the <link linkend="simplexml.examples-basic">basic usage</link> guide.
|
||||
</para>
|
||||
@@ -76,7 +76,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
include 'example.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$sxe = new SimpleXMLElement($xmlstr);
|
||||
$sxe->addAttribute('type', 'documentary');
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
<para>
|
||||
<note>
|
||||
<para>
|
||||
Listed examples may include <literal>example.php</literal>,
|
||||
Listed examples may include <literal>examples/simplexml-data.php</literal>,
|
||||
which refers to the XML string found in the first example
|
||||
of the <link linkend="simplexml.examples-basic">basic usage</link> guide.
|
||||
</para>
|
||||
@@ -114,7 +114,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
include 'example.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
|
||||
$sxe = new SimpleXMLElement($xmlstr);
|
||||
echo $sxe->movie[0]->title;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<para>
|
||||
<note>
|
||||
<para>
|
||||
Listed examples may include <literal>example.php</literal>,
|
||||
Listed examples may include <literal>examples/simplexml-data.php</literal>,
|
||||
which refers to the XML string found in the first example
|
||||
of the <link linkend="simplexml.examples-basic">basic usage</link> guide.
|
||||
</para>
|
||||
@@ -44,7 +44,7 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include 'example.php';
|
||||
include 'examples/simplexml-data.php';
|
||||
$sxe = new SimpleXMLElement($xmlstr);
|
||||
|
||||
echo $sxe->getName() . "\n";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<book xml:id="book.xml" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<book xml:id="book.xml" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
|
||||
<?phpdoc extension-membership="bundledexternal" ?>
|
||||
<title>XML Parser</title>
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$file = "data.xml";
|
||||
$file = "examples/book.xml";
|
||||
$depth = 0;
|
||||
|
||||
function startElement($parser, $name, $attrs)
|
||||
@@ -67,7 +67,7 @@ xml_parser_free($xml_parser);
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$file = "data.xml";
|
||||
$file = "examples/book.xml";
|
||||
$map_array = array(
|
||||
"BOLD" => "B",
|
||||
"EMPHASIS" => "I",
|
||||
@@ -135,7 +135,7 @@ xml_parser_free($xml_parser);
|
||||
<para>
|
||||
<example>
|
||||
<title>External Entity Example</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" annotations="non-interactive">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$file = "xmltest.xml";
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$stream = fopen('large.xml', 'r');
|
||||
$stream = fopen('examples/book-simple.xml', 'r');
|
||||
$parser = xml_parser_create();
|
||||
|
||||
xml_set_element_handler(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<book xml:id="book.xmlreader" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<book xml:id="book.xmlreader" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
|
||||
<?phpdoc extension-membership="bundledexternal" ?>
|
||||
<title>XMLReader</title>
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$xml = XMLReader::open('test.xml');
|
||||
$xml = XMLReader::open('examples/book-simple.xml');
|
||||
|
||||
// The validate parser option must be enabled for
|
||||
// this method to work properly
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<book xml:id="book.xmlwriter" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<book xml:id="book.xmlwriter" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
|
||||
<?phpdoc extension-membership="bundledexternal" ?>
|
||||
<title>XMLWriter</title>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user