Skip to content

Commit d816a0f

Browse files
committed
Enable WASM for book.var, and tweak examples
1 parent 45042fe commit d816a0f

15 files changed

+59
-119
lines changed

reference/var/book.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
33

4-
<book xml:id="book.var" xmlns="http://docbook.org/ns/docbook">
4+
<book xml:id="book.var" xmlns="http://docbook.org/ns/docbook" annotations="interactive">
55
<?phpdoc extension-membership="core" ?>
66
<title>Variable handling</title>
77

reference/var/functions/get-debug-type.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ echo get_debug_type(0.1), PHP_EOL;
152152
echo get_debug_type("foo"), PHP_EOL;
153153
echo get_debug_type([]), PHP_EOL;
154154
155-
$fp = fopen(__FILE__, 'rb');
155+
$fp = fopen('/examples/book.xml', 'rb');
156156
echo get_debug_type($fp), PHP_EOL;
157157
158158
fclose($fp);

reference/var/functions/get-resource-type.xml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
<para>
4242
If the given <parameter>resource</parameter> is a resource, this function
4343
will return a string representing its type. If the type is not identified
44-
by this function, the return value will be the string
44+
by this function, the return value will be the string
4545
<literal>Unknown</literal>.
4646
</para>
4747
<para>
48-
This function will return &null; and generate an error if
48+
This function will return &null; and generate an error if
4949
<parameter>resource</parameter> is not a <type>resource</type>.
5050
</para>
5151
</refsect1>
@@ -60,18 +60,13 @@
6060
<?php
6161
$fp = fopen("foo", "w");
6262
echo get_resource_type($fp) . "\n";
63-
64-
// As of PHP 8.0.0, the following does not work anymore. The curl_init function returns a CurlHandle object now.
65-
$c = curl_init();
66-
echo get_resource_type($c) . "\n";
6763
?>
6864
]]>
6965
</programlisting>
7066
&example.outputs.7;
7167
<screen role="php">
7268
<![CDATA[
7369
stream
74-
curl
7570
]]>
7671
</screen>
7772
</example>

reference/var/functions/intval.xml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -131,27 +131,27 @@
131131
<programlisting role="php">
132132
<![CDATA[
133133
<?php
134-
echo intval(42); // 42
135-
echo intval(4.7); // 4
136-
echo intval('42'); // 42
137-
echo intval('+42'); // 42
138-
echo intval('-42'); // -42
139-
echo intval(042); // 34
140-
echo intval('042'); // 42
141-
echo intval(1e10); // 10000000000
142-
echo intval('1e10'); // 10000000000
143-
echo intval(0x1A); // 26
144-
echo intval('0x1A'); // 0
145-
echo intval('0x1A', 0); // 26
146-
echo intval(42000000); // 42000000
147-
echo intval(420000000000000000000); // -4275113695319687168
148-
echo intval('420000000000000000000'); // 9223372036854775807
149-
echo intval(42, 8); // 42
150-
echo intval('42', 8); // 34
151-
echo intval(array()); // 0
152-
echo intval(array('foo', 'bar')); // 1
153-
echo intval(false); // 0
154-
echo intval(true); // 1
134+
echo intval(42), PHP_EOL; // 42
135+
echo intval(4.7), PHP_EOL; // 4
136+
echo intval('42'), PHP_EOL; // 42
137+
echo intval('+42'), PHP_EOL; // 42
138+
echo intval('-42'), PHP_EOL; // -42
139+
echo intval(042), PHP_EOL; // 34
140+
echo intval('042'), PHP_EOL; // 42
141+
echo intval(1e10), PHP_EOL; // 10000000000
142+
echo intval('1e10'), PHP_EOL; // 10000000000
143+
echo intval(0x1A), PHP_EOL; // 26
144+
echo intval('0x1A'), PHP_EOL; // 0
145+
echo intval('0x1A', 0), PHP_EOL; // 26
146+
echo intval(42000000), PHP_EOL; // 42000000
147+
echo intval(420000000000000000000), PHP_EOL; // -4275113695319687168
148+
echo intval('420000000000000000000'), PHP_EOL; // 9223372036854775807
149+
echo intval(42, 8), PHP_EOL; // 42
150+
echo intval('42', 8), PHP_EOL; // 34
151+
echo intval(array()), PHP_EOL; // 0
152+
echo intval(array('foo', 'bar')), PHP_EOL; // 1
153+
echo intval(false), PHP_EOL; // 0
154+
echo intval(true), PHP_EOL; // 1
155155
?>
156156
]]>
157157
</programlisting>

reference/var/functions/is-bool.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ $b = 0;
5252
5353
// Since $a is a boolean, it will return true
5454
if (is_bool($a) === true) {
55-
echo "Yes, this is a boolean";
55+
echo "Yes, this is a boolean\n";
5656
}
5757
5858
// Since $b is not a boolean, it will return false
5959
if (is_bool($b) === false) {
60-
echo "No, this is not a boolean";
60+
echo "No, this is not a boolean\n";
6161
}
6262
?>
6363
]]>

reference/var/functions/is-countable.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ var_dump(is_countable([1, 2, 3])); // bool(true)
7878
var_dump(is_countable(new ArrayIterator(['foo', 'bar', 'baz']))); // bool(true)
7979
var_dump(is_countable(new ArrayIterator())); // bool(true)
8080
var_dump(is_countable(new stdClass())); // bool(false)
81-
81+
?>
8282
]]>
8383
</programlisting>
8484
</example>

reference/var/functions/is-null.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,10 @@ var_dump(is_null($inexistent), is_null($foo));
5656
?>
5757
]]>
5858
</programlisting>
59-
<screen>
60-
<![CDATA[
61-
Notice: Undefined variable: inexistent in ...
62-
bool(true)
63-
bool(true)
64-
]]>
65-
</screen>
6659
</example>
6760
</para>
6861
</refsect1>
62+
6963
<refsect1 role="seealso">
7064
&reftitle.seealso;
7165
<para>

reference/var/functions/is-scalar.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@
7373
function show_var($var)
7474
{
7575
if (is_scalar($var)) {
76-
echo $var;
76+
echo $var, PHP_EOL;
7777
} else {
7878
var_dump($var);
7979
}
8080
}
81+
8182
$pi = 3.1416;
8283
$proteins = array("hemoglobin", "cytochrome c oxidase", "ferredoxin");
8384

reference/var/functions/isset.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ $var = '';
8080
8181
// This will evaluate to TRUE so the text will be printed.
8282
if (isset($var)) {
83-
echo "This var is set so I will print.";
83+
echo "This var is set so I will print.", PHP_EOL;
8484
}
8585
8686
// In the next examples we'll use var_dump to output
@@ -107,7 +107,7 @@ var_dump(isset($foo)); // FALSE
107107
</para>
108108
<para>
109109
This also work for elements in arrays:
110-
<informalexample>
110+
<example>
111111
<programlisting role="php">
112112
<![CDATA[
113113
<?php
@@ -130,7 +130,7 @@ var_dump(isset($a['cake']['a']['b'])); // FALSE
130130
?>
131131
]]>
132132
</programlisting>
133-
</informalexample>
133+
</example>
134134
</para>
135135
<example>
136136
<title><function>isset</function> on String Offsets</title>

reference/var/functions/print-r.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
<pre>
102102
<?php
103103
$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
104-
print_r ($a);
104+
print_r($a);
105105
?>
106106
</pre>
107107
]]>
@@ -134,6 +134,8 @@ Array
134134
<?php
135135
$b = array ('m' => 'monkey', 'foo' => 'bar', 'x' => array ('x', 'y', 'z'));
136136
$results = print_r($b, true); // $results now contains output from print_r
137+
138+
print_r($results);
137139
?>
138140
]]>
139141
</programlisting>

0 commit comments

Comments
 (0)