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 to 56 and version up
Search
Yoshihide Taniguchi
May 16, 2017
Programming
1
2.2k
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
300
PHP7.2で始める型宣言
gs3
0
470
ISUCONのすゝめ // OUR ISUCON
gs3
3
1.2k
オブジェクト指向設計とデザインパターンの基礎 / Basics of object oriented design and design pattern
gs3
2
100k
1人から始める大規模Webアプリケーションの言語バージョンアップ / version up PHP in large scale application
gs3
20
4.8k
あの日見たバグを僕達はまだ公式ドキュメントで見れない / The bug we saw that day
gs3
1
1.4k
ペパボを支える大統一CI基盤と人々
gs3
2
3.8k
PHP 5.3.x のアプリを PHP 7.0.x で動かすためにした n 個のこと
gs3
1
1.5k
今までやってきたこと これからやりたいこと
gs3
0
2.2k
Other Decks in Programming
See All in Programming
“Seeing Like a Programmer”—Resiliency, Limits, and Moral Hazards in Software Engineering (LambdaConf 2024)
chriskrycho
0
240
Balkan Ruby 2024 — How and why to run SQLite on Rails in production
fractaledmind
0
100
CREってこういうこと? 体験入社 - 提案資料 - / what-is-cre-trial-employment
shinden
1
560
Fast JSX: Don't clone props object #28768
yossydev
1
200
Git Lint
bkuhlmann
4
760
dbtのドメイン分割による データ基盤の改善とDigdagとの連携
sakama
0
470
Apache Hive 4 on Treasure Data
ryukobayashi
1
440
検証も兼ねて個人開発でHonoとかと向き合った話
hanetsuki
1
1.4k
Folding Cheat Sheet #4
philipschwarz
PRO
0
100
VS Code をプロダクトにどう取り込むか
onomax
1
770
Build Apps for iOS, Android & Desktop in 100% Kotlin With Compose Multiplatform (mDevCamp 2024)
zsmb
0
480
Goのmultiple errorsについて (2024年4月版)
syumai
4
1.2k
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.1k
The Power of CSS Pseudo Elements
geoffreycrofte
62
5k
Into the Great Unknown - MozCon
thekraken
15
1k
Adopting Sorbet at Scale
ufuk
69
8.6k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
226
51k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
117
18k
Facilitating Awesome Meetings
lara
43
5.6k
Six Lessons from altMBA
skipperchong
22
3k
The MySQL Ecosystem @ GitHub 2015
samlambert
244
12k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
8
3.4k
Atom: Resistance is Futile
akmur
260
25k
Git: the NoSQL Database
bkeepers
PRO
423
63k
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