mirror of
https://github.com/php/doc-en.git
synced 2026-03-23 23:32:18 +01:00
Typographic fixes. (#4909)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<title>Functional Operators</title>
|
||||
<titleabbrev>Functional</titleabbrev>
|
||||
<para>
|
||||
PHP 8.5 and later supports one operator that works directly on callables. The <literal>|></literal>
|
||||
PHP 8.5 and later supports one operator that works directly on callables. The <literal>|></literal>
|
||||
operator, or “pipe,” accepts a single-parameter callable on the right and passes
|
||||
the left-side value to it, evaluating to the callable's result. The callable
|
||||
on the right may be any valid PHP callable: a <classname>Closure</classname>,
|
||||
@@ -13,15 +13,15 @@
|
||||
<para>
|
||||
That means the following two lines are logically equivalent.
|
||||
<example>
|
||||
<title>Using <literal>|></literal></title>
|
||||
<title>Using <literal>|></literal></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$result = "Hello World" |> strlen(...);
|
||||
print $result . PHP_EOL;
|
||||
echo $result, PHP_EOL;
|
||||
|
||||
$result = strlen("Hello World");
|
||||
print $result . PHP_EOL;
|
||||
echo $result, PHP_EOL;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -38,7 +38,7 @@ print $result . PHP_EOL;
|
||||
For a single call that is not especially useful. It becomes useful when multiple calls are chained together.
|
||||
That is, the following two code fragments are logically equivalent:
|
||||
<example>
|
||||
<title>Chaining |> calls</title>
|
||||
<title>Chaining |> calls</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
@@ -48,7 +48,7 @@ $result = "PHP Rocks"
|
||||
|> (fn($x) => array_map(strtoupper(...), $x))
|
||||
|> (fn($x) => array_filter($x, fn($v) => $v != 'O'))
|
||||
;
|
||||
print $result . PHP_EOL;
|
||||
echo $result, PHP_EOL;
|
||||
|
||||
$temp = "PHP Rocks";
|
||||
$temp = htmlentities($temp);
|
||||
@@ -56,7 +56,7 @@ $temp = str_split($temp);
|
||||
$temp = array_map(strtoupper(...), $temp);
|
||||
$temp = array_filter($temp, fn($v) => $v != 'O');
|
||||
$result = $temp;
|
||||
print $result . PHP_EOL;
|
||||
echo $result, PHP_EOL;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
Reference in New Issue
Block a user