Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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.3k
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
310
PHP7.2で始める型宣言
gs3
0
530
ISUCONのすゝめ // OUR ISUCON
gs3
3
1.3k
オブジェクト指向設計とデザインパターンの基礎 / Basics of object oriented design and design pattern
gs3
2
100k
1人から始める大規模Webアプリケーションの言語バージョンアップ / version up PHP in large scale application
gs3
20
5k
あの日見たバグを僕達はまだ公式ドキュメントで見れない / The bug we saw that day
gs3
1
1.5k
ペパボを支える大統一CI基盤と人々
gs3
2
4k
PHP 5.3.x のアプリを PHP 7.0.x で動かすためにした n 個のこと
gs3
1
1.5k
今までやってきたこと これからやりたいこと
gs3
0
2.3k
Other Decks in Programming
See All in Programming
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
1
130
useSyncExternalStoreを使いまくる
ssssota
2
450
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
140
Seamless Flutter Native Integration: FFI & Pigeon - Dreamwalker (JaichangPark / 박제창) @FlutterKaigi2024
itsmedreamwalker
0
120
React CompilerとFine Grained Reactivityと宣言的UIのこれから / The next chapter of declarative UI
ssssota
7
3.4k
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
120
CSC305 Lecture 26
javiergs
PRO
0
130
気をつけたい!Desktop対応で陥りやすい罠とその対策
goto_tsl
0
200
Haze - Real time background blurring
chrisbanes
1
450
Full stack testing :: basic to basic
up1
1
890
Arm移行タイムアタック
qnighy
0
410
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
100
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Why Our Code Smells
bkeepers
PRO
334
57k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Raft: Consensus for Rubyists
vanstee
136
6.7k
What's in a price? How to price your products and services
michaelherold
243
12k
The Cost Of JavaScript in 2023
addyosmani
45
6.9k
Visualization
eitanlees
145
15k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Writing Fast Ruby
sferik
627
61k
Scaling GitHub
holman
458
140k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
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