[DOC-CVS] [doc-en] master: Fix examples whose documented output doesn't match Run code (#5718)
[email protected] (KentarouTakeda via GitHub) Fri, 31 Jul 2026 17:54:33 +0000
| Newsgroups | php.doc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: KentarouTakeda (KentarouTakeda)
Committer: GitHub (web-flow)
Pusher: kamil-tekiela
Date: 2026-07-31T18:54:31+01:00
Commit: https://github.com/php/doc-en/commit/17c238517825dfb7ec3edfef5972acd944ffbc1e
Raw diff: https://github.com/php/doc-en/commit/17c238517825dfb7ec3edfef5972acd944ffbc1e.diff
Fix examples whose documented output doesn't match Run code (#5718)
* Fix two broken examples
withfragment.xml had no opening <?php, so pressing Run code printed the
source instead of running it.
getshortname.xml called getName() on the ReflectionConstant::getShortName()
page, so it printed the fully qualified name.
* Fix the XML declaration in DOM <screen> blocks
saveXML() emits the declaration, but these screens either drop it
entirely or drop the encoding the document declares.
* Use the formatting var_dump() and print_r() actually produce in <screen>
These screens use indentation, spacing or a layout the functions never
emit: "[0] => " where var_dump() writes "[0]=>" on its own line, hand
alignment print_r() does not pad, and spaces where the data holds tabs.
* Fix <screen> values that do not match the actual output
Each of these differs from what the example prints: stale line numbers
and offsets, a wrong ordering, a dropped semicolon, a missing line,
screens quoting the example's own strings wrongly, and output split
across lines that is really printed on one.
* Pin the timestamp in the date('T') example
date('T') with no timestamp follows daylight saving, so the page showed
PST for half the year and PDT for the other half. Pinning a winter
moment makes the documented output true all year, so the <screen> is
unchanged.
* Address review feedback
- goto: drop the stack trace, which PHP 8.5 adds and 8.2-8.4 do not, and
mark the screen as similar output instead
- object to array cast: split the screen into PHP 8.0 and PHP 8.1, the
version where the property order changed
- createFromString: indent the source by four spaces rather than remove a
space from the output
- preg_replace: echo a newline so the count stays on its own line
Changed paths:
M language/control-structures/foreach.xml
M language/control-structures/goto.xml
M language/control-structures/match.xml
M language/control-structures/switch.xml
M language/oop5/basic.xml
M language/oop5/lazy-objects.xml
M language/oop5/overloading.xml
M language/types/array.xml
M language/types/callable.xml
M reference/array/functions/array-fill.xml
M reference/array/functions/array-map.xml
M reference/array/functions/array-udiff-assoc.xml
M reference/array/functions/array-unique.xml
M reference/array/functions/array-unshift.xml
M reference/array/functions/natsort.xml
M reference/datetime/formats.xml
M reference/datetime/functions/date-default-timezone-get.xml
M reference/datetime/functions/date-sun-info.xml
M reference/dom/dom/characterdata/before.xml
M reference/dom/dom/characterdata/remove.xml
M reference/dom/dom/characterdata/replacewith.xml
M reference/dom/dom/htmldocument/createfromstring.xml
M reference/dom/domdocument/append.xml
M reference/dom/domdocumentfragment/replacechildren.xml
M reference/dom/domelement/before.xml
M reference/dom/domelement/getattributenames.xml
M reference/dom/domnode/getlineno.xml
M reference/libxml/functions/libxml-get-errors.xml
M reference/libxml/functions/libxml-set-external-entity-loader.xml
M reference/pcre/functions/preg-replace.xml
M reference/reflection/reflectionclass/getdefaultproperties.xml
M reference/reflection/reflectionclass/getdoccomment.xml
M reference/reflection/reflectionconstant/getshortname.xml
M reference/simplexml/functions/simplexml-load-string.xml
M reference/simplexml/simplexmlelement/children.xml
M reference/simplexml/simplexmlelement/getDocNamespaces.xml
M reference/strings/functions/explode.xml
M reference/strings/functions/htmlentities.xml
M reference/strings/functions/ltrim.xml
M reference/strings/functions/rtrim.xml
M reference/strings/functions/str-word-count.xml
M reference/strings/functions/strtok.xml
M reference/strings/functions/trim.xml
M reference/uri/uri/rfc3986/uri/withfragment.xml
M reference/xmlwriter/xmlwriter/writecdata.xml
Diff:
diff --git a/language/control-structures/foreach.xml b/language/control-structures/foreach.xml
index ded0de4dee78..a424f4964612 100644
--- a/language/control-structures/foreach.xml
+++ b/language/control-structures/foreach.xml
@@ -177,6 +177,8 @@ foreach ($array as list($a, $b)) {
<![CDATA[
A: 1; B: 2
A: 3; B: 4
+A: 1; B: 2
+A: 3; B: 4
]]>
</screen>
</informalexample>
diff --git a/language/control-structures/goto.xml b/language/control-structures/goto.xml
index 9422253da580..1884d4bd851f 100644
--- a/language/control-structures/goto.xml
+++ b/language/control-structures/goto.xml
@@ -91,7 +91,7 @@ for ($i = 0, $j = 50; $i < 100; $i++) {
echo "$i = $i";
]]>
</programlisting>
- &example.outputs;
+ &example.outputs.similar;
<screen>
<![CDATA[
Fatal error: 'goto' into loop or switch statement is disallowed in script on line 2
diff --git a/language/control-structures/match.xml b/language/control-structures/match.xml
index 9d663afe0e07..6735f154d18a 100644
--- a/language/control-structures/match.xml
+++ b/language/control-structures/match.xml
@@ -228,7 +228,7 @@ object(UnhandledMatchError)#1 (7) {
["file":protected]=>
string(6) "script"
["line":protected]=>
- int(6)
+ int(5)
["trace":"Error":private]=>
array(0) {
}
diff --git a/language/control-structures/switch.xml b/language/control-structures/switch.xml
index 3b4303a4a7f0..cd829abd611d 100644
--- a/language/control-structures/switch.xml
+++ b/language/control-structures/switch.xml
@@ -336,14 +336,15 @@ switch($beer)
&example.outputs;
<screen>
<![CDATA[
-
Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead in script on line 6
Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead in script on line 7
Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead in script on line 8
-Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead in script on line 11
+Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead in script on line 9
+
+Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead in script on line 12
Please make a new selection...
]]>
</screen>
diff --git a/language/oop5/basic.xml b/language/oop5/basic.xml
index 74d188eaa695..ea87be554544 100644
--- a/language/oop5/basic.xml
+++ b/language/oop5/basic.xml
@@ -326,8 +326,8 @@ var_dump($assigned);
NULL
NULL
object(SimpleClass)#1 (1) {
- ["var"]=>
- string(30) "$assigned will have this value"
+ ["var"]=>
+ string(30) "$assigned will have this value"
}
]]>
</screen>
@@ -535,7 +535,7 @@ $extended->displayVar();
<screen>
<![CDATA[
Extending class
-Parent Class
+Parent class
]]>
</screen>
</example>
diff --git a/language/oop5/lazy-objects.xml b/language/oop5/lazy-objects.xml
index a985e53da624..ec99a2e0afed 100644
--- a/language/oop5/lazy-objects.xml
+++ b/language/oop5/lazy-objects.xml
@@ -82,8 +82,8 @@ var_dump($lazyObject->prop);
<screen>
<![CDATA[
lazy ghost object(Example)#3 (0) {
-["prop"]=>
-uninitialized(int)
+ ["prop"]=>
+ uninitialized(int)
}
string(7) "Example"
Example::__construct
diff --git a/language/oop5/overloading.xml b/language/oop5/overloading.xml
index dd2ec3cbba04..d9ccc717343d 100644
--- a/language/oop5/overloading.xml
+++ b/language/oop5/overloading.xml
@@ -227,8 +227,7 @@ Privates are visible inside the class, so __get() not used...
Privates not visible outside of class, so __get() is used...
Getting 'hidden'
-
-Notice: Undefined property via __get(): hidden in <file> on line 70 in <file> on line 29
+Notice: Undefined property via __get(): hidden in script on line 71 in script on line 27
]]>
</screen>
diff --git a/language/types/array.xml b/language/types/array.xml
index a45389522570..a81ce3188f44 100644
--- a/language/types/array.xml
+++ b/language/types/array.xml
@@ -1120,7 +1120,7 @@ var_dump((array) new B());
?>
]]>
</programlisting>
- &example.outputs;
+ &example.outputs.80;
<screen>
<![CDATA[
array(3) {
@@ -1131,6 +1131,19 @@ array(3) {
["AA"]=>
NULL
}
+]]>
+ </screen>
+ &example.outputs.81;
+ <screen>
+ <![CDATA[
+array(3) {
+ ["AA"]=>
+ NULL
+ ["BA"]=>
+ NULL
+ ["AA"]=>
+ NULL
+}
]]>
</screen>
</example>
diff --git a/language/types/callable.xml b/language/types/callable.xml
index 1b9fa4aa8ebc..71df364a1bcb 100644
--- a/language/types/callable.xml
+++ b/language/types/callable.xml
@@ -266,7 +266,7 @@ Hello World!
Hello World!
Hello World!
-Deprecated: Callables of the form ["B", "parent::who"] are deprecated in script on line 41
+Deprecated: Callables of the form ["B", "parent::who"] are deprecated in script on line 44
A
Hello PHP!
]]>
diff --git a/reference/array/functions/array-fill.xml b/reference/array/functions/array-fill.xml
index 8c8e822eea0a..9265b98ad076 100644
--- a/reference/array/functions/array-fill.xml
+++ b/reference/array/functions/array-fill.xml
@@ -124,11 +124,11 @@ print_r($a);
<![CDATA[
Array
(
- [5] => banana
- [6] => banana
- [7] => banana
- [8] => banana
- [9] => banana
+ [5] => banana
+ [6] => banana
+ [7] => banana
+ [8] => banana
+ [9] => banana
[10] => banana
)
]]>
diff --git a/reference/array/functions/array-map.xml b/reference/array/functions/array-map.xml
index b1c6a8aacfa2..e1e59abcb647 100644
--- a/reference/array/functions/array-map.xml
+++ b/reference/array/functions/array-map.xml
@@ -167,6 +167,14 @@ Array
[3] => 8
[4] => 10
)
+Array
+(
+ [0] => 2
+ [1] => 4
+ [2] => 6
+ [3] => 8
+ [4] => 10
+)
]]>
</screen>
</example>
diff --git a/reference/array/functions/array-udiff-assoc.xml b/reference/array/functions/array-udiff-assoc.xml
index dd1e023486fe..d03f53bf32e1 100644
--- a/reference/array/functions/array-udiff-assoc.xml
+++ b/reference/array/functions/array-udiff-assoc.xml
@@ -106,18 +106,19 @@ Array
(
[0.1] => cr Object
(
- [priv_member:private] => 9
+ [priv_member:cr:private] => 9
)
[0.5] => cr Object
(
- [priv_member:private] => 12
+ [priv_member:cr:private] => 12
)
[0] => cr Object
(
- [priv_member:private] => 23
+ [priv_member:cr:private] => 23
)
+
)
]]>
</screen>
diff --git a/reference/array/functions/array-unique.xml b/reference/array/functions/array-unique.xml
index 88a79d128721..2ec4980816ab 100644
--- a/reference/array/functions/array-unique.xml
+++ b/reference/array/functions/array-unique.xml
@@ -158,8 +158,10 @@ var_dump($result);
<screen role="php">
<![CDATA[
array(2) {
- [0] => int(4)
- [2] => string(1) "3"
+ [0]=>
+ int(4)
+ [2]=>
+ string(1) "3"
}
]]>
</screen>
diff --git a/reference/array/functions/array-unshift.xml b/reference/array/functions/array-unshift.xml
index bcb308139d0b..111d17349855 100644
--- a/reference/array/functions/array-unshift.xml
+++ b/reference/array/functions/array-unshift.xml
@@ -101,13 +101,13 @@ var_dump($queue);
<screen role="php">
<![CDATA[
array(4) {
- [0] =>
+ [0]=>
string(5) "apple"
- [1] =>
+ [1]=>
string(9) "raspberry"
- [2] =>
+ [2]=>
string(6) "orange"
- [3] =>
+ [3]=>
string(6) "banana"
}
]]>
diff --git a/reference/array/functions/natsort.xml b/reference/array/functions/natsort.xml
index e88a1c13e8c6..ed33dc1b0f80 100644
--- a/reference/array/functions/natsort.xml
+++ b/reference/array/functions/natsort.xml
@@ -153,7 +153,6 @@ Array
[1] => 3
[5] => 9
)
-
Zero padding
Array
(
@@ -168,8 +167,8 @@ Array
(
[5] => 0
[1] => 8
- [3] => 009
[0] => 09
+ [3] => 009
[2] => 10
[4] => 011
)
diff --git a/reference/datetime/formats.xml b/reference/datetime/formats.xml
index 7a4d96fb53e8..ad3fb08a8be5 100644
--- a/reference/datetime/formats.xml
+++ b/reference/datetime/formats.xml
@@ -90,7 +90,7 @@ var_dump($res["warnings"]);
<screen>
<![CDATA[
array(1) {
- [11] =>
+ [11]=>
string(27) "The parsed date was invalid"
}
]]>
diff --git a/reference/datetime/functions/date-default-timezone-get.xml b/reference/datetime/functions/date-default-timezone-get.xml
index b949851ef160..e3740af77c2d 100644
--- a/reference/datetime/functions/date-default-timezone-get.xml
+++ b/reference/datetime/functions/date-default-timezone-get.xml
@@ -83,7 +83,8 @@ date.timezone: Europe/London
<![CDATA[
<?php
date_default_timezone_set('America/Los_Angeles');
-echo date_default_timezone_get() . ' => ' . date('e') . ' => ' . date('T');
+$ts = mktime(0, 0, 0, 1, 1, 2024);
+echo date_default_timezone_get() . ' => ' . date('e') . ' => ' . date('T', $ts);
]]>
</programlisting>
&example.outputs;
diff --git a/reference/datetime/functions/date-sun-info.xml b/reference/datetime/functions/date-sun-info.xml
index 6b9a781ee1d7..185e446e52cd 100644
--- a/reference/datetime/functions/date-sun-info.xml
+++ b/reference/datetime/functions/date-sun-info.xml
@@ -282,7 +282,7 @@ echo "Length of day: ",
&example.outputs;
<screen>
<![CDATA[
-Length of day: 13h 56s
+Length of day: 13h 53s
]]>
</screen>
</example>
diff --git a/reference/dom/dom/characterdata/before.xml b/reference/dom/dom/characterdata/before.xml
index 3bcf13ae87ba..9ec57f225cbb 100644
--- a/reference/dom/dom/characterdata/before.xml
+++ b/reference/dom/dom/characterdata/before.xml
@@ -40,7 +40,7 @@ echo $doc->saveXML();
&example.outputs;
<screen>
<![CDATA[
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<container>hello<beautiful/><![CDATA[world]]]]><![CDATA[></container>
]]>
</screen>
diff --git a/reference/dom/dom/characterdata/remove.xml b/reference/dom/dom/characterdata/remove.xml
index fa9b2a31c617..3ebe46d05d37 100644
--- a/reference/dom/dom/characterdata/remove.xml
+++ b/reference/dom/dom/characterdata/remove.xml
@@ -39,7 +39,7 @@ echo $doc->saveXML();
&example.outputs;
<screen>
<![CDATA[
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<container><world/></container>
]]>
</screen>
diff --git a/reference/dom/dom/characterdata/replacewith.xml b/reference/dom/dom/characterdata/replacewith.xml
index 9e41aad17c45..9a3baa081502 100644
--- a/reference/dom/dom/characterdata/replacewith.xml
+++ b/reference/dom/dom/characterdata/replacewith.xml
@@ -40,7 +40,7 @@ echo $doc->saveXML();
&example.outputs;
<screen>
<![CDATA[
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<container>beautiful<world/></container>
]]>
</screen>
diff --git a/reference/dom/dom/htmldocument/createfromstring.xml b/reference/dom/dom/htmldocument/createfromstring.xml
index c7dc4f8f3d51..22b9ca0215dc 100644
--- a/reference/dom/dom/htmldocument/createfromstring.xml
+++ b/reference/dom/dom/htmldocument/createfromstring.xml
@@ -73,7 +73,7 @@ $dom = Dom\HTMLDocument::createFromString(<<<'HTML'
<!DOCTYPE html>
<html>
<body>
- <p>Hello, world!</p>
+ <p>Hello, world!</p>
</body>
</html>
HTML);
diff --git a/reference/dom/domdocument/append.xml b/reference/dom/domdocument/append.xml
index fde57677de18..a7330f8b99ad 100644
--- a/reference/dom/domdocument/append.xml
+++ b/reference/dom/domdocument/append.xml
@@ -43,6 +43,7 @@ echo $doc->saveXML();
&example.outputs;
<screen>
<![CDATA[
+<?xml version="1.0"?>
<hello/>
beautiful
<world/>
diff --git a/reference/dom/domdocumentfragment/replacechildren.xml b/reference/dom/domdocumentfragment/replacechildren.xml
index a7fc0f64640e..44ffb1221e92 100644
--- a/reference/dom/domdocumentfragment/replacechildren.xml
+++ b/reference/dom/domdocumentfragment/replacechildren.xml
@@ -45,8 +45,7 @@ echo $doc->saveXML($fragment);
&example.outputs;
<screen>
<![CDATA[
-beautiful
-<world/>
+beautiful<world/>
]]>
</screen>
</example>
diff --git a/reference/dom/domelement/before.xml b/reference/dom/domelement/before.xml
index c51c2c788646..4e7b2f1538f0 100644
--- a/reference/dom/domelement/before.xml
+++ b/reference/dom/domelement/before.xml
@@ -44,6 +44,7 @@ echo $doc->saveXML();
&example.outputs;
<screen>
<![CDATA[
+<?xml version="1.0"?>
hello
<beautiful/>
<world/>
diff --git a/reference/dom/domelement/getattributenames.xml b/reference/dom/domelement/getattributenames.xml
index 3e3cb67ed516..58c52fac93fb 100644
--- a/reference/dom/domelement/getattributenames.xml
+++ b/reference/dom/domelement/getattributenames.xml
@@ -46,12 +46,12 @@ var_dump($dom->documentElement->getAttributeNames());
<screen>
<![CDATA[
array(3) {
- [0]=>
- string(10) "xmlns:some"
- [1]=>
- string(9) "some:test"
- [2]=>
- string(5) "test2"
+ [0]=>
+ string(10) "xmlns:some"
+ [1]=>
+ string(9) "some:test"
+ [2]=>
+ string(5) "test2"
}
]]>
</screen>
diff --git a/reference/dom/domnode/getlineno.xml b/reference/dom/domnode/getlineno.xml
index 6a8ccd44c1b5..fa05a3de839e 100644
--- a/reference/dom/domnode/getlineno.xml
+++ b/reference/dom/domnode/getlineno.xml
@@ -60,7 +60,7 @@ printf('The <node> tag is defined on line %d', $dom->getElementsByTagName('node'
&example.outputs;
<screen>
<![CDATA[
-The <node> tag is defined in line 3
+The <node> tag is defined on line 3
]]>
</screen>
</example>
diff --git a/reference/libxml/functions/libxml-get-errors.xml b/reference/libxml/functions/libxml-get-errors.xml
index dbcfac898b78..03a8fe4e667c 100644
--- a/reference/libxml/functions/libxml-get-errors.xml
+++ b/reference/libxml/functions/libxml-get-errors.xml
@@ -103,10 +103,10 @@ function display_xml_error($error, $xml)
<screen>
<![CDATA[
<titles>PHP: Behind the Parser</title>
-----------------------------------------------^
+-----------------------------------------^
Fatal Error 76: Opening and ending tag mismatch: titles line 4 and title
Line: 4
- Column: 46
+ Column: 41
--------------------------------------------
]]>
diff --git a/reference/libxml/functions/libxml-set-external-entity-loader.xml b/reference/libxml/functions/libxml-set-external-entity-loader.xml
index fcff518c25b6..49527aa52b2a 100644
--- a/reference/libxml/functions/libxml-set-external-entity-loader.xml
+++ b/reference/libxml/functions/libxml-set-external-entity-loader.xml
@@ -140,10 +140,14 @@ var_dump($dd->validate());
string(10) "-//FOO/BAR"
string(25) "http://example.com/foobar"
array(4) {
- ["directory"] => NULL
- ["intSubName"] => NULL
- ["extSubURI"] => NULL
- ["extSubSystem"] => NULL
+ ["directory"]=>
+ NULL
+ ["intSubName"]=>
+ NULL
+ ["extSubURI"]=>
+ NULL
+ ["extSubSystem"]=>
+ NULL
}
bool(true)
]]>
diff --git a/reference/pcre/functions/preg-replace.xml b/reference/pcre/functions/preg-replace.xml
index cfee1a313ee8..6cdb16b7b8ce 100644
--- a/reference/pcre/functions/preg-replace.xml
+++ b/reference/pcre/functions/preg-replace.xml
@@ -275,6 +275,7 @@ echo $str;
$count = 0;
echo preg_replace(array('/\d/', '/\s/'), '*', 'xp 4 to', -1 , $count);
+echo "\n";
echo $count; //3
?>
]]>
diff --git a/reference/reflection/reflectionclass/getdefaultproperties.xml b/reference/reflection/reflectionclass/getdefaultproperties.xml
index 068d931a5074..66e271cd8ce1 100644
--- a/reference/reflection/reflectionclass/getdefaultproperties.xml
+++ b/reference/reflection/reflectionclass/getdefaultproperties.xml
@@ -68,16 +68,16 @@ var_dump($reflectionClass->getDefaultProperties());
<screen>
<![CDATA[
array(5) {
- ["staticProperty"]=>
- string(14) "staticProperty"
- ["property"]=>
- string(15) "propertyDefault"
- ["privateProperty"]=>
- string(22) "privatePropertyDefault"
- ["defaultlessProperty"]=>
- NULL
- ["inheritedProperty"]=>
- string(16) "inheritedDefault"
+ ["staticProperty"]=>
+ string(14) "staticProperty"
+ ["property"]=>
+ string(15) "propertyDefault"
+ ["privateProperty"]=>
+ string(22) "privatePropertyDefault"
+ ["defaultlessProperty"]=>
+ NULL
+ ["inheritedProperty"]=>
+ string(16) "inheritedDefault"
}
]]>
</screen>
diff --git a/reference/reflection/reflectionclass/getdoccomment.xml b/reference/reflection/reflectionclass/getdoccomment.xml
index 650d2e504cd3..ab3b1392703d 100644
--- a/reference/reflection/reflectionclass/getdoccomment.xml
+++ b/reference/reflection/reflectionclass/getdoccomment.xml
@@ -56,7 +56,7 @@ var_dump($rc->getDocComment());
&example.outputs;
<screen>
<![CDATA[
-string(61) "/**
+string(60) "/**
* A test class
*
* @param foo bar
diff --git a/reference/reflection/reflectionconstant/getshortname.xml b/reference/reflection/reflectionconstant/getshortname.xml
index 8a419067f7ff..4ac18a994536 100644
--- a/reference/reflection/reflectionconstant/getshortname.xml
+++ b/reference/reflection/reflectionconstant/getshortname.xml
@@ -39,7 +39,7 @@ namespace Foo;
const BAR = 'bar';
-echo (new \ReflectionConstant('Foo\BAR'))->getName();
+echo (new \ReflectionConstant('Foo\BAR'))->getShortName();
?>
]]>
</programlisting>
diff --git a/reference/simplexml/functions/simplexml-load-string.xml b/reference/simplexml/functions/simplexml-load-string.xml
index 2003795e80fc..b3b9da19e54e 100644
--- a/reference/simplexml/functions/simplexml-load-string.xml
+++ b/reference/simplexml/functions/simplexml-load-string.xml
@@ -127,11 +127,12 @@ print_r($xml);
<![CDATA[
SimpleXMLElement Object
(
- [title] => Forty What?
- [from] => Joe
- [to] => Jane
- [body] =>
- I know that's the answer -- but what's the question?
+ [title] => Forty What?
+ [from] => Joe
+ [to] => Jane
+ [body] =>
+ I know that's the answer -- but what's the question?
+
)
]]>
</screen>
diff --git a/reference/simplexml/simplexmlelement/children.xml b/reference/simplexml/simplexmlelement/children.xml
index 28ccfbb8badd..bb23775c3527 100644
--- a/reference/simplexml/simplexmlelement/children.xml
+++ b/reference/simplexml/simplexmlelement/children.xml
@@ -94,8 +94,7 @@ foreach ($xml->children() as $second_gen) {
&example.outputs;
<screen>
<![CDATA[
-The person begot a son who begot a daughter; The person
-begot a daughter who begot a son; and that son begot a son
+ The person begot a son who begot a daughter; The person begot a daughter who begot a son; and that son begot a son
]]>
</screen>
</example>
diff --git a/reference/simplexml/simplexmlelement/getDocNamespaces.xml b/reference/simplexml/simplexmlelement/getDocNamespaces.xml
index 7d17fe92d94f..3b1132bcf49b 100644
--- a/reference/simplexml/simplexmlelement/getDocNamespaces.xml
+++ b/reference/simplexml/simplexmlelement/getDocNamespaces.xml
@@ -82,8 +82,8 @@ var_dump($namespaces);
<screen>
<![CDATA[
array(1) {
- ["p"]=>
- string(21) "http://example.org/ns"
+ ["p"]=>
+ string(21) "http://example.org/ns"
}
]]>
</screen>
diff --git a/reference/strings/functions/explode.xml b/reference/strings/functions/explode.xml
index 4e186e77a108..4b26c4834bab 100644
--- a/reference/strings/functions/explode.xml
+++ b/reference/strings/functions/explode.xml
@@ -163,20 +163,22 @@ var_dump( explode( ',', $input3 ) );
&example.outputs;
<screen>
<![CDATA[
-array(1)
-(
- [0] => string(5) "hello"
-)
-array(2)
-(
- [0] => string(5) "hello"
- [1] => string(5) "there"
-)
-array(2)
-(
- [0] => string(0) ""
- [1] => string(0) ""
-)
+array(1) {
+ [0]=>
+ string(5) "hello"
+}
+array(2) {
+ [0]=>
+ string(5) "hello"
+ [1]=>
+ string(5) "there"
+}
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+}
]]>
</screen>
</example>
diff --git a/reference/strings/functions/htmlentities.xml b/reference/strings/functions/htmlentities.xml
index 7e612d0c721c..0368910464d6 100644
--- a/reference/strings/functions/htmlentities.xml
+++ b/reference/strings/functions/htmlentities.xml
@@ -207,7 +207,7 @@ echo htmlentities($str, ENT_COMPAT);
<![CDATA[
A 'quote' is <b>bold</b>
-A 'quote' is <b>bold</b>
+A 'quote' is <b>bold</b>
]]>
</screen>
</example>
diff --git a/reference/strings/functions/ltrim.xml b/reference/strings/functions/ltrim.xml
index 0ddd401718fa..f5b3847386e0 100644
--- a/reference/strings/functions/ltrim.xml
+++ b/reference/strings/functions/ltrim.xml
@@ -88,8 +88,8 @@ var_dump($clean);
&example.outputs;
<screen>
<![CDATA[
-string(32) " These are a few words :) ... "
-string(16) " Example string
+string(32) " These are a few words :) ... "
+string(16) " Example string
"
string(11) "Hello World"
diff --git a/reference/strings/functions/rtrim.xml b/reference/strings/functions/rtrim.xml
index 75d16b01ac40..df23e95bd358 100644
--- a/reference/strings/functions/rtrim.xml
+++ b/reference/strings/functions/rtrim.xml
@@ -87,15 +87,15 @@ var_dump($clean);
&example.outputs;
<screen>
<![CDATA[
-string(32) " These are a few words :) ... "
-string(16) " Example string
+string(32) " These are a few words :) ... "
+string(16) " Example string
"
string(11) "Hello World"
-string(30) " These are a few words :) ..."
-string(26) " These are a few words :)"
+string(30) " These are a few words :) ..."
+string(26) " These are a few words :)"
string(9) "Hello Wor"
-string(15) " Example string"
+string(15) " Example string"
]]>
</screen>
</example>
diff --git a/reference/strings/functions/str-word-count.xml b/reference/strings/functions/str-word-count.xml
index 3f5cc84c0a9e..9ae7ccdd82f8 100644
--- a/reference/strings/functions/str-word-count.xml
+++ b/reference/strings/functions/str-word-count.xml
@@ -149,18 +149,16 @@ Array
[5] => good
[6] => today
)
-
Array
(
[0] => Hello
[6] => fri
[10] => nd
[14] => you're
- [29] => looking
- [46] => good
- [51] => today
+ [28] => looking
+ [45] => good
+ [50] => today
)
-
Array
(
[0] => Hello
@@ -170,7 +168,6 @@ Array
[4] => good
[5] => today
)
-
7
]]>
</screen>
diff --git a/reference/strings/functions/strtok.xml b/reference/strings/functions/strtok.xml
index e1a3076198ac..0607bff3f46c 100644
--- a/reference/strings/functions/strtok.xml
+++ b/reference/strings/functions/strtok.xml
@@ -145,8 +145,8 @@ var_dump($first_token, $second_token);
&example.outputs;
<screen>
<![CDATA[
- string(9) "something"
- bool(false)
+string(9) "something"
+bool(false)
]]>
</screen>
</example>
diff --git a/reference/strings/functions/trim.xml b/reference/strings/functions/trim.xml
index 7813d77128b8..6c1f0c1354c6 100644
--- a/reference/strings/functions/trim.xml
+++ b/reference/strings/functions/trim.xml
@@ -89,8 +89,8 @@ var_dump($clean);
&example.outputs;
<screen>
<![CDATA[
-string(32) " These are a few words :) ... "
-string(16) " Example string
+string(32) " These are a few words :) ... "
+string(16) " Example string
"
string(11) "Hello World"
diff --git a/reference/uri/uri/rfc3986/uri/withfragment.xml b/reference/uri/uri/rfc3986/uri/withfragment.xml
index 287bcf812b77..a8760f6926fc 100644
--- a/reference/uri/uri/rfc3986/uri/withfragment.xml
+++ b/reference/uri/uri/rfc3986/uri/withfragment.xml
@@ -48,6 +48,7 @@
<title><methodname>Uri\Rfc3986\Uri::withFragment</methodname> basic example</title>
<programlisting role="php">
<![CDATA[
+<?php
$uri = new \Uri\Rfc3986\Uri("https://example.com/#foo");
$uri = $uri->withFragment("bar");
diff --git a/reference/xmlwriter/xmlwriter/writecdata.xml b/reference/xmlwriter/xmlwriter/writecdata.xml
index 323a7ad1532a..0e010c3d190b 100644
--- a/reference/xmlwriter/xmlwriter/writecdata.xml
+++ b/reference/xmlwriter/xmlwriter/writecdata.xml
@@ -95,9 +95,10 @@ echo $xml->outputMemory(true);
&example.outputs;
<screen>
<![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
<mydoc>
<myele>
- <mycdataelement><![CDATA[text for inclusion as CData]]></mycdataelement>
+ <mycdataelement><![CDATA[text for inclusion as CData]]]]><![CDATA[></mycdataelement>
</myele>
</mydoc>
]]>