Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PHP 5.4 ~ 5.6 での追加機能のおさらいとバージョンアップへの誘い / php54 ...
Search
Yoshihide Taniguchi
May 16, 2017
Programming
1
2.4k
PHP 5.4 ~ 5.6 での追加機能のおさらいとバージョンアップへの誘い / php54 to 56 and version up
社内のテックミーティングの資料(公開 ver)です
Yoshihide Taniguchi
May 16, 2017
Tweet
Share
More Decks by Yoshihide Taniguchi
See All by Yoshihide Taniguchi
PHP がフロントエンドエンジニアになってみた // from PHPer to Frontend
gs3
1
320
PHP7.2で始める型宣言
gs3
0
560
ISUCONのすゝめ // OUR ISUCON
gs3
3
1.4k
オブジェクト指向設計とデザインパターンの基礎 / Basics of object oriented design and design pattern
gs3
2
100k
1人から始める大規模Webアプリケーションの言語バージョンアップ / version up PHP in large scale application
gs3
20
5.1k
あの日見たバグを僕達はまだ公式ドキュメントで見れない / The bug we saw that day
gs3
1
1.5k
ペパボを支える大統一CI基盤と人々
gs3
2
4.1k
PHP 5.3.x のアプリを PHP 7.0.x で動かすためにした n 個のこと
gs3
1
1.6k
今までやってきたこと これからやりたいこと
gs3
0
2.3k
Other Decks in Programming
See All in Programming
TypeScript製IaCツールのAWS CDKが様々な言語で実装できる理由 ~他言語変換の仕組み~ / cdk-language-transformation
gotok365
6
340
TSConfig Solution Style & subpath imports to switch types on a per-file basis
maminami373
1
160
生成AI時代のフルスタック開発
kenn
9
2k
型安全なDrag and Dropの設計を考える
yudppp
5
630
少数精鋭エンジニアがフルスタック力を磨く理由 -そしてAI時代へ-
rebase_engineering
0
110
OpenTelemetry + LLM = OpenLLMetry!?
yunosukey
2
260
AI Coding Agent Enablement in TypeScript
yukukotani
15
6k
#QiitaBash TDDでAIに設計イメージを伝える
ryosukedtomita
2
1.2k
AWS診断200件の分析から見る頻出指摘と対策
shoodagiri
0
110
がんばりすぎないコーディングルール運用術
tsukakei
1
110
事業KPIを基に価値の解像度を上げる
nealle
0
180
Duke on CRaC with Jakarta EE
ivargrimstad
1
590
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
336
57k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
14
880
We Have a Design System, Now What?
morganepeng
52
7.6k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.4k
It's Worth the Effort
3n
184
28k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Facilitating Awesome Meetings
lara
54
6.4k
Typedesign – Prime Four
hannesfritz
41
2.6k
BBQ
matthewcrist
88
9.6k
Art, The Web, and Tiny UX
lynnandtonic
298
21k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
For a Future-Friendly Web
brad_frost
178
9.7k
Transcript
d1)1όʔδϣϯ্͕Δͱศར͡ΌΜd &$ج൫୩ޱHVTTBO &$5FDI.5( 1)1dͰͷ Ճػೳͷ͓͞Β͍ͱ όʔδϣϯΞοϓͷ༠͍
എܠ wϩʔϧ"ͷ1)1͕Y͔ΒʹͳΓ·ͨ͠ w1)1dͰՃ͞ΕͨػೳΛ͍ͬͯ·͔͢ʁ w͋Μ·ΓΓ·ͤΜͰͨ͠ wطଘͷίʔυ͔Β৽ػೳֶ·ͤΜ wࣗൃతͳֶश͕ඞཁͰ͢ ˞ ॾ͔Βɺࠓ͙͢͏ͱ͕͋Γ·͢
1)1Ͱͳ͘ΛબΜͩཧ༝ʹ͍ͭͯˣΛࢀর wIUUQTTQFBLFSEFDLDPNHTBGBMTFSJKJBOUBCBHVXPQVEB IBNBEBHPOHTIJEPLJZVNFOUPEFKJBOSFOBJ
ࠓճ͓͍ͨ͜͠ͱ w1)1͔Β·ͰʹՃ͞Εͨػೳʹ͍ͭͯ wಠஅͱภݟͰൈਮ͠·ͨ͠ w1)1dͰඇਪʹͳΔɾແ͘ͳΔػೳʹ͍ͭͯ w͜Ε͔ΒΘͳ͍ɺফͤͦ͏ͳΒফ͢ wόʔδϣϯΞοϓͯ͠Έ·ͤΜ͔ʁͱ͍͏͓༠͍
✂͔͜͜Βػೳհ✂
<>ʢdʣ wBSSBZ Λ<>Ͱॻ͚ΔΑ͏ʹͳͬͨ $men = [‘Jon’, ‘Bon’, ‘Jovi’]; //
$men = array(‘Jon’, ‘Bon’, ‘Jovi’); ͱՁ
"SSBZ 4USJOHͷσϦϑΝϨϯεʢdʣ wྻɺจࣈྻΛఴࣈͰࢀরͰ͖ΔΑ͏ʹͳͬͨ print [1, 2, 3, 4][0]; // =>
1 print ‘colorme’[4]; // => ‘r’
ؔͷฦΓͷఴࣈࢀর d wؔʢϝιουʣͷฦΓΛఴ͑ࣈͰࢀরͰ͖ΔΑ͏ʹͳͬͨ function simple_array() { return [1, 2, 3];
} print simple_array()[1]; // => 2
BSSBZ@DPMVNO wd wଟ࣍ݩྻʹ͋Δ ಛఆͷΩʔͷΛऔಘ͢Δؔ $array = [ [ 'id'
=> 101, 'name' => 'Jim', 'position' => 'guitar', ], [ 'id' => 102, 'name' => 'Corey', 'position' => 'vocals', ] ]; print_r(array_column($array, 'name')); // Array // ( // [0] => Jim // [1] => Corey // )
FNQUZ ʹ͕ࣜͤΔΑ͏ʹ d w͋ͷFNQUZ ʹม͚ͩͰͳ͕ࣜͤ͘ΔΑ͏ʹͳͬͨ if (empty(current_gmo_point())) {
// . . . }
DPOTUͰྻͷఆԽ d wDPOTUΩʔϫʔυͰྻΛఆͱͯ͠એݴͰ͖ΔΑ͏ʹͳͬͨ const ARR = [1, 2, 3]; print_r(ARR);
// Array // ( // [0] => 1 // [1] => 2 // [2] => 3 // )
ԋࢉࢠ d wՄมҾΛԋࢉࢠͰ දݱͰ͖ΔΑ͏ʹͳͬͨ w͞ΒGVOD@HFU@BSHT function puts_nums(...$nums) {
print_r($nums); } puts_nums(1); puts_nums(1, 2); puts_nums(1, 2, 3); // Array // ( // [0] => 1 // ) // Array // ( // [0] => 1 // [1] => 2 // ) // Array // ( // [0] => 1 // [1] => 2 // [2] => 3 // )
ྦྷԋࢉࢠ d w✽✽Ͱྦྷԋࢉ͕Ͱ͖ΔΑ͏ʹͳͬͨ wॖೖԋࢉࢠͷ✽✽Ճ $num = 3 ** 2; $num
**= 2; print $num; // => 81
pOBMMZΩʔϫʔυ d wUSZDBUDIϒϩοΫʹpOBMMZΩʔϫʔυ͕Ճ͞Εͨ try { throw new Exception('5'); } catch
(Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } finally { echo '͍'; } // => Caught exception: 5 // ͍
։ൃ༻$-*8FCαʔό d w8FCαʔό͕$-*Ϟʔυͷ1)1ʹΈࠐ·Εͨ wϧʔτ63-ʹΞΫηε͢ΔͱJOEFY QIQcIUNM Λฦͯ͘͠ΕΔ $ echo ‘Hello, PHP!’
> index.html $ php -S localhost:7000 -t . $ curl localhost:7000 Hello, PHP!
USBJU w୯Ұܧঝͳ1)1Ͱ ৼΔ͍Λڞ༗͢ΔΈ wྫʣը૾ΛΞοϓϩʔυͰ͖Δ ৼΔ͍Λڞ༗͢Δ trait UploadImage { function upload($imagePath)
{ //... } } class ProductController { use UploadImage; // ... } class ShopController { use UploadImage; // ... }
։ൃ༻$-*8FCαʔό d w8FCαʔό͕$-*Ϟʔυͷ1)1ʹΈࠐ·Εͨ wϧʔτ63-ʹΞΫηε͢ΔͱJOEFY QIQcIUNM Λฦͯ͘͠ΕΔ $ echo ‘Hello, PHP!’
> index.html $ php -S localhost:7000 -t . $ curl localhost:7000 Hello, PHP!
େ͖͍ϑΝΠϧͷΞοϓϩʔυ d w(#Ҏ্ͷϑΝΠϧΞοϓϩʔυͰ͖ΔΑ͏ʹͳͬͨ
1)1Ͱ͑ͳ͘ͳΔػೳ ൈਮ wNZTRM@ ؔ wFSFH ؔ wDBMM@VTFS@NFUIPE DBMM@VTFS@NFUIPE@BSSBZ wQIQJOJͷBTQ@UBHT
wNFNDBDIFQFDMFYUFOTJPO wNFNDBDIF`E`FYUFOTJPO1)1YʹରԠ
1)1dͰEFQSFDBUFͳػೳ ൈਮ w w $MBTT/BNF ͳίϯετϥΫλ w ඇTUBUJDϝιουͷTUBUJDͳݺͼग़͠ w
w FYUNDSZQUϞδϡʔϧ w 3'$ͷஈ֊ w @@BVUPMPBE w DSFBUF@GVODUJPO w FBDI w ୈҾͷͳ͍QBSTF@TUS
w ࠓճհ͠ͳ͔ͬͨ w ՃͷؔɺΫϥεɺϝιου w ඇਪɾআͱͳͬͨػೳɾϞδϡʔϧ w ʹ͍ͭͯ1)1ϚχϡΞϧͷʹ͋Γ·͢ w IUUQQIQOFUNBOVBMKBBQQFOEJDFTQIQ
✂͜͜·Ͱػೳհ✂
όʔδϣϯΞοϓͯ͠Έ·ͤΜ͔ʁ wΔͱීஈͷ։ൃͰಘΒΕͳ͍ݟ͕ಘΒΕ·͢ wࠓͳΒϩʔϧ"Ͱͬͨͱ͖ͷϩάΛࢀߟॻʹͰ͖·͢ʂ w͔͠ϩʔϧ"ΑΓίʔυྔଟ͍ϩʔϧແ͍ʂ wόʔδϣϯΞοϓͷλεΫ͕߱ͬͯ͘Δ͜ͱແ͍ wΔؾ͋Δਓ͕֮ޛܾΊͯ࣌ؒऔΓʹߦ͔͘͠ͳ͍ wΔͳΒશྗͰαϙʔτ͠·͢ʂʂʂʂ̍̍
ͯ͢ͷґଘؔʹ͍ͭͯ࠷৽ͷόʔδϣϯʹै͢Δʹෆஅ ͷྗ͕ඞཁ͕ͩɺී௨ɺͦΕΛߦ͏͚ͩͷϝϦοτ͕͋Δɻ ΞοϓάϨʔυʹΑͬͯɺ͠͠ੑೳͷ্όάϑΟοΫε ͕ಘΒΕΔ͠ɺͱ͖ʹக໋తͳηΩϡϦςΟͷύον͕ͯΒ ΕΔɻͦΕ͚ͩΛͯʹґଘؔͷΞοϓάϨʔυΛߦ͏͖ Ͱͳ͍͕ɺҰൠʹɺΞοϓάϨʔυྑ͍͜ͱͰ͋Δɻ ΫϦεɾόʔνϟϧʮϨΨγʔιϑτΣΞվળΨΠυʯᠳӭࣾ
ࢀߟɿ1)1ͷαϙʔτόʔδϣϯ IUUQQIQOFUTVQQPSUFEWFSTJPOTQIQΑΓ ηΩϡϦςΟαϙʔτΕͨͷ͕લ ʂ ͍ͬͺ͍ηΩϡϦςΟαϙʔτ
όʔδϣϯΞοϓͷԸܙ wύϑΥʔϚϯεͷ্Ҏ֎ʹɺجຊతʹ͍͍͜ͱͣ͘Ί wηΩϡϦςΟϦεΫ͕Լ͕Δ w։ൃͷॊೈੑɾݎ࿚ੑ্͕͕Δɾ্͛͘͢ͳΔ wʢ࠷৽ͷʣػೳ͕૿͑Δ wͦΕΛલఏͱͨ͠ศརͳϥΠϒϥϦ͕͑Δ wʹղܾͷબࢶ͕૿͑Δ wࣾ֎ͷใʹΞλον͘͢͠ͳΔɾՌΛࣾ֎ʹൃද͘͢͠ͳΔ wͳͲͳͲ
·ͱΊ w1)1dͰՃ͞ΕͨػೳΛհ͠·ͨ͠ w1)1dͰඇਪɾআͱͳͬͨػೳΛհ͠·ͨ͠ w1)1ͷόʔδϣϯΞοϓʹ༠͍·ͨ͠
ࢀߟ wQIQϚχϡΞϧɿ wIUUQQIQOFUNBOVBMKBBQQFOEJDFTQIQ wQIQSGD wIUUQTXJLJQIQOFUSGD