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
15
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
17
札幌PHP勉強会 2年の振り返りと反省と今後の展望
uegaki_masahiro
0
78
印刷オペレーターから札幌市IT人材雇用プログラム研修1期生としてITキャリアを始めたお話
uegaki_masahiro
0
56
PHP_CakePHP_で開発された国産CMSのbaserCMSのお話.pdf
uegaki_masahiro
0
110
Other Decks in Programming
See All in Programming
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
350
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
360
Ghostty + Neovimで作る 透明でカッコ良い開発環境
j341nono
0
130
スマートフォンでモールス信号を送受信する 〜スマートフォンのLEDとカメラで作る光通信の設計と実装〜
atsuki_seo
0
200
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
3k
カツオ、ご期待ください
suneo3476
0
110
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
440
Heart of Swift Concurrency
koher
0
1k
wkhtmltopdfの次どうするか問題2026
willnet
2
1.8k
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.4k
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
180
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
7
5k
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
331
22k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Mind Mapping
helmedeiros
1
370
Navigating Team Friction
lara
192
16k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
250
The SEO identity crisis: Don't let AI make you average
varn
0
560
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
550
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
680
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
340
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で追加された パイプ演算子を使うことによってすっきり書けるように なった。 まとめ
モータルコンバット/ネクストラウンドを 観に行こう! 最後に