Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
PHP8.5から導入されたパイプ演算子
Search
上垣雅弘 / UEGAKI Masahiro
June 22, 2026
Programming
16
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PHP8.5から導入されたパイプ演算子
えびてく #7 で発表したライトニングトークのスライドです。
https://ebitech.connpass.com/event/393193/
上垣雅弘 / UEGAKI Masahiro
June 22, 2026
More Decks by 上垣雅弘 / UEGAKI Masahiro
See All by 上垣雅弘 / UEGAKI Masahiro
札幌PHP勉強会で得た知見とPHP_Sapporoでやりたい事
uegaki_masahiro
0
20
札幌PHP勉強会 2年の振り返りと反省と今後の展望
uegaki_masahiro
0
82
印刷オペレーターから札幌市IT人材雇用プログラム研修1期生としてITキャリアを始めたお話
uegaki_masahiro
0
60
PHP_CakePHP_で開発された国産CMSのbaserCMSのお話.pdf
uegaki_masahiro
0
110
Other Decks in Programming
See All in Programming
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
220
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
650
Workers Cache を知る
syumai
0
370
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
28
33k
The Rails Doctrine Decade
koic
2
590
Event is what happens
moro
2
850
すこし踏み込む CancellationToken
htkym
2
1.7k
ジョジョの世界をXRで再現する
mofurune
0
170
最近”作らせてる” ローカルAIアプリの話
akit37
0
480
気持ちぃ〜角丸 Squircle
ryu1013
0
310
AWSに止められる覚悟してますか?
morizo_1984
2
540
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
How to train your dragon (web standard)
notwaldorf
96
6.9k
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
710
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
How GitHub (no longer) Works
holman
316
150k
Typedesign – Prime Four
hannesfritz
42
3.2k
Amusing Abliteration
ianozsvald
1
350
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
630
Game over? The fight for quality and originality in the time of robots
wayneb77
1
310
Technical Leadership for Architectural Decision Making
baasie
3
600
Into the Great Unknown - MozCon
thekraken
41
2.8k
Transcript
PHP8.5から導入されたパイプ演算子 2026年6月20日 えびてく #7 上垣 雅弘
自己紹介 名前 : 上垣 雅弘 ハンドルネーム : 睦月 Xアカウント :
@ichigatu 札幌PHP勉強会の運営をしています。 猫の動画を見るのが好きです。 最近、モータルコンバット/ネクストラウンドを 映画館で観ました。
パイプ演算子(|>)が追加されました。 マニュアルより抜粋 https://www.php.net/manual/ja/language.ope rators.functional.php 最新のPHP8.5に追加された機能は?
PHP 8.5 以降では、callable に直接値を渡す演算子を サポートしています。 |> 演算子、または "パイプ" は、 右辺にパラメーターをひとつ取る
callable を受け入れ、 左辺値をそれに渡し、callable の結果を評価します。 右 辺の callable は、有効な PHP の callable であれば何 でも構いません: つまり、Closure、 第一級callableを 生成する記法、 __invoke() を実装したオブジェクトな どです。 パイプ演算子とは?
分かりやすく書くと、|>の左辺で実行した関数の結果を 右辺に渡して実行できる。 なるほど、分からん
<?php $result = "Hello World" |> strlen(...); echo $result, PHP_EOL;
$result = strlen("Hello World"); echo $result, PHP_EOL; ?> 例1 |> を使う
11 11 例1 出力結果
<?php $temp = "PHP Rocks"; $temp = htmlentities($temp); $temp =
str_split($temp); $temp = array_map(strtoupper(...), $temp); $temp = array_filter($temp, fn($v) => $v != 'O'); $result = $temp; print_r($result); ?> 例2 |> の呼び出しをチェインさせる パイプ演算子を使わない場合
Array ( [0] => P [1] => H [2] =>
P [3] => [4] => R [6] => C [7] => K [8] => S ) 実行結果
• $tempに”PHP Rocks”という文字列を格納 • HTML特殊文字の変換 • 文字列を「1文字ずつ」の配列に分解 • すべての文字を「大文字」に変換 •
文字 'O' を取り除く(フィルタリング) • 結果の代入と出力 何をやってるのか?
何行も$tempに格納されている配列が変更されて デバッグ時にも何回も変更されるので メンテンナンス性が非常に悪い。 とはいえネストして1行でまとめると、コードの 可読性が悪くなってしまう。 そこでパイプ演算子。 メンテナンス性の問題
<?php $result = "PHP Rocks" |> htmlentities(...) |> str_split(...) |>
(fn($x) => array_map(strtoupper(...), $x)) |> (fn($x) => array_filter($x, fn($v) => $v != 'O')) ; print_r($result); ?> パイプ演算子を使った場合
1つの変数や配列に対して処理をする場合、 数行に渡って関数を実行したり、 関数のネストをするよりも、PHP8.5で追加された パイプ演算子を使うことによってすっきり書けるように なった。 まとめ
モータルコンバット/ネクストラウンドを 観に行こう! 最後に