ãã ãã7çªç®ã®ããŒãžã§ã³ã§ã¯ãå»æ¢ãããæ©èœãåé€ããããããäžäœäºææ§ã«é¢ããåé¡ãçºçããå€ãã¢ããªã±ãŒã·ã§ã³ãæ°ããããŒãžã§ã³ã«ç§»è¡ããããšãå°é£ã«ãªããŸããã ãã®èšäºã¯ãæ°ããã¢ããªã±ãŒã·ã§ã³ãäœæããããæ¢åã®ã¢ããªã±ãŒã·ã§ã³ãPHP 7ã«å€æããå Žåã®ã¯ã€ãã¯ã¬ã€ããšããŠåœ¹ç«ã¡ãŸãã
åŸ ã£ãŠãPHP 6ã¯ã©ãã§ããïŒ
PHPããã°ãã䜿çšããŠããªãå ŽåãPHP 6ãã©ãã«è¡ã£ãã®ãçåã«æããããããŸããããªãPHP 5ããPHP 7ã«çŽæ¥ãžã£ã³ãããã®ã§ãã ç°¡åã«èª¬æããŸãããPHP 6ããŒãžã§ã³ã®ãªãªãŒã¹ã¯è¡ãããŸããã§ããã PHPã¯äž»ã«Webéçºã§äœ¿çšããããããããŒãžã§ã³6ã®äž»ãªæ©èœã¯Unicodeæåã®ãµããŒãã§ããããWebã¯UnicodeãµããŒããå¿ èŠãšããããããã®å®è£ ã¯çã«ããªã£ãŠããŸãã
ã¢ã€ãã¢ã¯ãUnicodeãµããŒããã«ãŒãã«ã«çŽæ¥å®è£ ããããšã§ããã ãã®ã¢ãããŒãã¯ãå€æ°ã®ååãšé¢æ°ãšããŠã®æããªçµµæåã®äœ¿çšãããåœéçãªæååã®åŒ·åãªæ©èœãŸã§ãèšèªã®æ©èœãæ¡åŒµããããšã«ãªã£ãŠããŸãã ããšãã°ãå¥ã®èšèªãè±èªä»¥å€ã®å€§æåãšå°æåã䜿çšããå ŽåããŸãã¯äžåœèªã®ååãè±èªã®ååã«å€æããå Žåã
PHP6ã¯éå¿çã§ããããæ®å¿µã§ãã ãããã£ãŠã6çªç®ã®ããŒãžã§ã³ãã¹ãããããããã»ã¹ã§PHP7ãéå§ããŸããã
æ®å¿µãªããããã®éå¿çãªèšç»ã«ã¯äºæ³ä»¥äžã«å€ãã®åé¡ããããŸããã ã«ãŒãã«ã®å ŽåãšéèŠãªæ¡åŒµæ©èœã®å Žåã®äž¡æ¹ã§ãUnicodeããµããŒãããããã«ã³ãŒãããŒã¹ã®ã»ãšãã©ã移æ€ããå¿ èŠããããŸããã ããã«ãããä»ã®èšèªæ©èœã®éçºããã»ã¹ãé ããªããå€ãã®PHPéçºè ãæ··ä¹±ããŸããã ä»ã®éå£ãçŸããããããã€ãã£ãUnicodeãµããŒãã®éçºãžã®é¢å¿ãäœäžãããããŠãããžã§ã¯ãã¯å®å šã«æŸæ£ãããŸããã
ãŸããæžç±ãèšäºãªã©ã®å€ãã®ãªãœãŒã¹ãPHP 6ã®ååãšUnicodeãµããŒãã䜿çšããŠèšè¿°ãããŠããããã誀解ãé¿ããããã«ãæ°ããããŒãžã§ã³ã®ååãPHP 7ã«ããããšã«ããŸããã
å¯èœã§ããã°ãæãéå»ãæãäžããã®ããããŸãããã PHP 7ã®æ°æ©èœãèŠãŠã¿ãŸãããã
çç£æ§æŠäºãPHP 7察 PHP 5
å®è³ªçã«ãã¹ãŠã®æŽæ°ã«ãããããã©ãŒãã³ã¹ããããã«æ¹åãããŸããã ãã ããä»åã¯ã以åã®ããŒãžã§ã³ãšæ¯èŒããŠPHPã®ããã©ãŒãã³ã¹ãå€§å¹ ã«åäžããPHP 7ã®æãé åçãªæ©èœã®1ã€ã«ãªããŸãããããã¯ãPHPNGããããžã§ã¯ãïŒãphp new generationããŸãã¯ãphp new generation ããã©ã³ã¹ã¬ãŒã¿ ïŒãããã¯Zend Engineèªäœã«åœ±é¿ããŸããã
å éšããŒã¿æ§é ããªãã¡ã¯ã¿ãªã³ã°ããã³ãŒããæœè±¡æ§æããªãŒïŒASTïŒã«ã³ã³ãã€ã«ããåã«è¿œå ã®ã¹ããããè¿œå ãããšãåªããããã©ãŒãã³ã¹ãšããå¹ççãªã¡ã¢ãªå²ãåœãŠãå¯èœã«ãªããŸããã æ°å€èªäœã¯ææã«èŠããŸã-å®éã®ã¢ããªã±ãŒã·ã§ã³ã§å®è¡ããããã¹ãã¯ãPHP 7ãPHP 5.6ã®å¹³å2åã®é床ã§ãããã¯ãšãªåŠçäžã®ã¡ã¢ãªäœ¿çšéã50ïŒ å°ãªãããšã瀺ããŠããŸãã ãã® Zend ã€ã³ãã©ã°ã©ãã£ãã¯ãèŠãŠãã ãããããã¯ãããã€ãã®æåãªCMSãšãã¬ãŒã ã¯ãŒã¯ã®ããã©ãŒãã³ã¹ã瀺ããŠããŸãã
PHP 7ã¯èŠæ £ããŠããŸãããããã©ãŒãã³ã¹ãã調æŽããããŠããŸãã Zend Engineãæ¹åãããçç£æ§ãåäžãããããZend Engineãšä»¥åã®ããŒãžã§ã³ãšã®éã«å€§ããªéããçããŸããã
ã¡ã¢ãªæ¶è²»ãåæžããããšã§ã匱ãã³ã³ãã¥ãŒã¿ãŒã§ããªã¯ãšã¹ããããé©åã«åŠçã§ããããã«ãªããPHPã®åšãã«ãã€ã¯ããµãŒãã¹ãæ§ç¯ã§ããããã«ãªããŸãã å éšå€æŽãç¹ã«ASTã®å®è£ ã¯ãçç£æ§ãããã«é«ããããšãã§ããå°æ¥ã®æé©åã®æ©äŒãæäŸããŸãã JITã³ã³ãã€ã©ã®æ°ãããã€ãã£ãå®è£ ã¯ãå°æ¥ã®ããŒãžã§ã³ã§ã®éçºãæå³ããŠéçºãããŸããã
PHP 7ã®æ§æã·ã¥ã¬ãŒ
PHP 7ã§ã¯ãããã€ãã®æ°ããæ§æãå°å ¥ãããŸããã ç®ã楜ããŸããŠãããã³ãŒããæžãããã®ããè¯ããŸãã¯ããç°¡åãªæ¹æ³ãæäŸããã®ã§ããã°ãèšèªèªäœã®æ©èœã®ããã€ããæ¡åŒµããŠã¿ãŸãããïŒ
ã€ã³ããŒã宣èšã®ã°ã«ãŒãå
ããã§ãåãããŒã ã¹ããŒã¹ã®ã¯ã©ã¹ã®ã€ã³ããŒã宣èšã1è¡ã§ã°ã«ãŒãåã§ããŸãã ããã«ããã宣èšãç¹å®ã®æå³ã®ããæ¹æ³ã«æããããã³ãŒãã®æ°ãã€ããç¯çŽãããã§ããŸãã
use Framework\Module\Foo; use Framework\Module\Bar; use Framework\Module\Baz;
PHP 7ã§ã¯ã次ã®ããšãã§ããŸãã
use Framework\Module\{Foo, Bar, Baz};
ãŸãã¯ãè€æ°è¡ã¹ã¿ã€ã«ã奜ãå ŽåïŒ
use Framework\Module{ Foo, Bar, Baz };
ãã«åäœæŒç®å
PHPã®äžè¬çãªåé¡ã解決ããŸãã å¥ã®å€æ°ã«å²ãåœãŠãããŠããå€æ°ã«å€ãå²ãåœãŠããããæåŸã®å€æ°ã«å€ãå²ãåœãŠãããŠããªãå Žåãäœããã®æ瀺çãªå€ãå²ãåœãŠãå¿ èŠããããŸãã å€ãã®å ŽåããŠãŒã¶ãŒå ¥åãæäœãããšãã«çŸããŸãã
PHP 7ããåïŒ
if (isset($foo)) { $bar = $foo; } else { $bar = 'default'; // $bar 'default' $foo NULL }
PHP 7ã®å ŽåïŒ
$bar = $foo ?? 'default';
å€æ°ã®ãã§ãŒã³ã§äœ¿çšã§ããŸãïŒ
$bar = $foo ?? $baz ?? 'default';
å®å®è¹ãªãã¬ãŒã¿ãŒ
ãã¹ããŒã¹ã·ããã<=>æŒç®åã䜿çšãããšã2ã€ã®å€ã®3ã¬ãã«ã®æ¯èŒãå¯èœã«ãªãããããã®çå€ãŸãã¯äžçåŒã ãã§ãªããäžçåŒã®å Žåã«ã©ã¡ãã倧ããããç解ã§ãã1.0ãŸãã¯-1ãè¿ããŸãã
ãã®å Žåãå€ã®éãã«å¿ããŠããŸããŸãªã¢ã¯ã·ã§ã³ãå®è¡ã§ããŸãã
switch ($bar <=> $foo) { case 0: echo '$bar $foo '; case -1: echo '$foo '; case 1: echo '$bar '; }
æ¯èŒãããå€ã¯ãæŽæ°åãæµ®åå°æ°ç¹æ°ãæåååãããã«ã¯é ååã§ãã ç°ãªãå€ã¯äºãã«ã©ã®ããã«æ¯èŒãããŸããïŒ ããã¥ã¡ã³ããåç §ããŠãã ãã ã
PHP 7ã®æ°æ©èœ
ãã¡ãããPHP 7ã¯æ°ããå°è±¡çãªæ©èœãå°å ¥ããŸããã
ã¹ã«ã©ãŒãã©ã¡ãŒã¿ã®ã¿ã€ããšè¿ãããã¿ã€ãã®ãã³ã
PHP 7ã¯ãå¯èœãªãã©ã¡ãŒã¿ãŒåãšããŠæŽæ°ïŒintïŒãæµ®åå°æ°ç¹ïŒfloatïŒãè«çïŒboolïŒãããã³æååïŒstringïŒã®4ã€ã®ã¹ã«ã©ãŒåãè¿œå ããããšã«ãããã¡ãœããïŒã¯ã©ã¹ãã€ã³ã¿ãŒãã§ã€ã¹ãããã³é åïŒã®ãã©ã¡ãŒã¿ãŒã®æ¢åã®å®£èšãæ¡åŒµããŸããã
ããã«ããªãã·ã§ã³ã§ãé¢æ°ãŸãã¯ã¡ãœããã«ãã£ãŠè¿ãããçµæã®ã¿ã€ããæå®ã§ããŸãã ã¿ã€ãboolãintãfloatãstringãarrayãcallableãã¯ã©ã¹ãŸãã¯ã€ã³ã¿ãŒãã§ãŒã¹åãããã³parentããµããŒããããŠããŸãïŒã¯ã©ã¹ã¡ãœããã®å ŽåïŒã
class Calculator { // , integer public function addTwoInts(int $x, int $y): int { // , return $x + $y; } }
åã宣èšããããšã«ãããééçãªã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ããé¢æ°ãæäœãããšãã«äžæ£ãªå€ã®è»¢éãšæ»ããåé¿ã§ããŸãã ãã®ä»ã®å©ç¹ã¯ãããã¥ã¡ã³ã¿ãªãŒããŒãDocBlocksããªãå Žåã«ãã³ãŒãã®ããæ確ãªè¡šç€ºãæäŸããéçã³ãŒãã¢ãã©ã€ã¶ãŒãšIDEã®å€èŠ³ã§ãã
PHPã¯åã匱ãèšèªã§ãããããã³ã³ããã¹ãã«åºã¥ããŠããã€ãã®ãã©ã¡ãŒã¿ãŒå€ãšæ»ãå€ã®åãåŒçšãããŸãã intåã®å®£èšããããã©ã¡ãŒã¿ãŒãæã€é¢æ°ã«å€ã3ããæž¡ããšãã€ã³ã¿ãŒããªã¿ãŒã¯ãããæŽæ°ãšèŠãªãããšã©ãŒãçæããŸããã ãã®åäœã«æ £ããŠããªãå Žåã¯ãé©åãªãã£ã¬ã¯ãã£ããè¿œå ããããšã«ãããå³æ Œã¢ãŒã- å³æ Œã¢ãŒã -ã§äœæ¥ã§ããŸãã
declare(strict_types=1);
ã°ããŒãã«ãªãã·ã§ã³ã¯ã³ãŒããªããžããªãããªãã·ã§ã³ããªã³ã«ããŠãã¡ã€ã«ãéçºããããã®ãšç¡å¹ã«ããããã®ã«åå²ãããããç°ãªãèšå®ã®2ã€ã®ãªããžããªããã®ã³ãŒããæäœãããšãã®äºæž¬ã§ããªãåäœã«ã€ãªããããããã¡ã€ã«ããšã«åå¥ã«ã€ã³ã¹ããŒã«ãããŸãã
ãšã³ãžã³ã®äŸå€
ã«ãŒãã«ã¬ãã«ã®äŸå€ã®åºçŸã«ããã以åã¯ã¹ã¯ãªããã®å®è¡ãåæ¢ããå¯èœæ§ããã£ãèŽåœçãªãšã©ãŒãç°¡åã«ååããŠåŠçã§ããããã«ãªããŸããã
ååšããªãã¡ãœããã®åŒã³åºããªã©ã®ãšã©ãŒãã¹ã¯ãªãããåæ¢ããããšã¯ãªããªãã代ããã«try catchãããã¯ã§åŠçã§ããäŸå€ãã¹ããŒãããã¢ããªã±ãŒã·ã§ã³ã®ãšã©ãŒåŠçãæããã«æ¹åãããŸãã ããã¯ãèŽåœçãªãšã©ãŒããªããã°åèµ·åãå¿ èŠã«ãªãå¯èœæ§ããããããäžéšã®çš®é¡ã®ã¢ããªã±ãŒã·ã§ã³ããµãŒããŒãããŒã¢ã³ã«ãšã£ãŠéèŠã§ãã èŽåœçãªãšã©ãŒã¯ãã¹ããããžã§ã¯ãå šäœãããããããå¯èœæ§ããããããPHPUnitã®ãã¹ãã䜿ãããããªãã¯ãã§ãã ãšã©ãŒãšã¯ç°ãªããäŸå€ã¯ãã¹ãããšã«åå¥ã«åŠçã§ããŸãã
PHP 7ã¯èŠæ £ããããŒã«ã®ããã«èŠããŸãããé«ãããã©ãŒãã³ã¹ãç®æããŠããŸãã Zend Engineã®åèšèšãšé床ã®åäžã«ããã以åã®ããŒãžã§ã³ãšã®å€§ããªéããçããŸããã
PHP 7ã«ã¯ãçºçããå¯èœæ§ã®ããçš®é¡ã®ãšã©ãŒãåŠçããããã«èšèšãããæ°ããäŸå€ã¯ã©ã¹ãããªããããŸãã ããŒãžã§ã³éã®äºææ§ã確ä¿ããããã«ãæ°ããThrowableã€ã³ã¿ãŒãã§ã€ã¹ãè¿œå ãããŸãã ;ã«ãŒãã«ã¬ãã«ã®äŸå€ãšãŠãŒã¶ãŒã®äŸå€ã®äž¡æ¹ã§å®è£ ã§ããŸãã ãã®ã¢ãããŒãã¯ãã«ãŒãã«äŸå€ã«ããäŸå€ã®åºæ¬ã¯ã©ã¹ã®ç¶æ¿ãé²ãããã«å®è£ ãããŸããããã«ããã以åã¯ååšããªãã£ã以åã«èšè¿°ãããã³ãŒãã«äŸå€ãåºçŸããŸãã
PHP 7ããåã§ã¯ããã®ãããªã³ãŒãã¯èŽåœçãªã¹ã¯ãªããå®è¡ãšã©ãŒãåŒãèµ·ãããŠããŸããã
try { thisFunctionDoesNotEvenExist(); //() } catch (\EngineException $e) { // echo $e->getMessage(); }
å¿åã¯ã©ã¹
å¿åã¯ã©ã¹ã¯ãçããŠæ確ãªãªããžã§ã¯ãã®æ©èœãäœæããããã«äœ¿çšã§ããå¿åé¢æ°ã®ããšãã§ãã å¿åã¯ã©ã¹ã¯ãéåžžã®ãªããžã§ã¯ããšåãæ¹æ³ã§ç°¡åã«äœæããã³äœ¿çšã§ããŸãã ããã¯ããã¥ã¡ã³ãã®äŸã§ãã
PHP 7ããåïŒ
class MyLogger { public function log($msg) { print_r($msg . "\n"); } } $pusher->setLogger( new MyLogger() );
å¿åã¯ã©ã¹ã®äœ¿çšïŒ
$pusher->setLogger(new class { public function log($msg) { print_r($msg . "\n"); } });
å¿åã¯ã©ã¹ã¯ããŠãããã§ãã¹ãããå Žåãç¹ã«ãªããžã§ã¯ããšãµãŒãã¹ããã¹ãããéã«ã¢ãã¯ïŒå®éã®ãªããžã§ã¯ãã®åäœãã·ãã¥ã¬ãŒããã-ã»ãŒãã©ã³ã¹ã¬ãŒã¿ãŒïŒãè¡ãå Žåã«åœ¹ç«ã¡ãŸãã ããããååšããããšã§ãã¢ããã³ã°ã«äœ¿çšã§ããã€ã³ã¿ãŒãã§ã€ã¹ããµããŒãããã·ã³ãã«ãªãªããžã§ã¯ããäœæããããšã§ã倧ããªã¢ããã³ã°ã©ã€ãã©ãªãšãã¬ãŒã ã¯ãŒã¯ã®äœ¿çšãåé¿ã§ããŸãã
CSPRNGé¢æ°
æå·çã«å®å šãªæååãšæŽæ°ãçæããããã®2ã€ã®æ°ããæ©èœã æåã¯é·ã$ lenã®ã©ã³ãã ãªæååãè¿ããŸãïŒ
random_bytes(int $len);
2çªç®ã¯ã$ min ... $ maxã®ç¯å²ã®æ°å€ãè¿ããŸãã
random_int(int $min, int $max);
Unicodeã®ãšã¹ã±ãŒãã³ãŒãæ§æ
PHPããŒãžã§ã³7ããåã®ãã®ä»ã®å€ãã®èšèªãšã¯ç°ãªããPHPã§ã¯ãæååå ã®Unicodeæåã®ãšã¹ã±ãŒãã·ãŒã±ã³ã¹ãæå®ããæ¹æ³ããããŸããã§ããã ããã§ããšã¹ã±ãŒãã·ãŒã±ã³ã¹\ uã䜿çšããŠãUTF-8ã»ããã®ã³ãŒãã䜿çšããŠãã®ãããªæåãçæã§ããŸãã ããã¯ãæåãçŽæ¥æ¿å ¥ãããããåªããŠããŸã;ç®ã«èŠããªãæåããå€ä»¥å€ã®ã°ã©ãã£ãã¯è¡šç€ºãæã€æåã¯ãããé©åã«å¶åŸ¡ãããŸãã
echo "\u{1F602}"; //
以åã«åäœããæåã®\ uãã¢ã䜿çšããŠããã³ãŒãã¯ãåäœãå€æŽããããããããŒãžã§ã³7ã§ã¯æ£ããåäœããªãããšã«æ³šæããŠãã ããã
æŽæ°ããããžã§ãã¬ãŒã¿ãŒ
PHPã®ãžã§ãã¬ãŒã¿ãŒã«ãããã€ãã®çŽ æŽãããæ°æ©èœããããŸãã çŸåšãreturnã¹ããŒãã¡ã³ãããããããã䜿çšããŠãå埩ã®å®äºæã«é¢é£ããŠããæçµå€ãè¿ãããšãã§ããŸãã ãžã§ãã¬ãŒã¿ã®æ£ããå®è¡ã確èªããããã«äœ¿çšã§ããŸãã ããšãã°ããšã©ãŒãªãã§å®è¡ããããã©ããã確èªãããããçºçããç¶æ³ããžã§ãã¬ãŒã¿ãŒãåŒã³åºããã³ãŒããæ£ããåŠçã§ããããã«ããŸãã
ããã«ããžã§ãã¬ãŒã¿ãŒã¯ä»ã®ãžã§ãã¬ãŒã¿ãŒããåŒãè¿ãããè¿ãããã§ããŸãã ãããã£ãŠãè€éãªæäœãããåçŽãªæäœã«å解ã§ããŸãã
function genA() { yield 2; yield 3; yield 4; } function genB() { yield 1; yield from genA(); // 'genA' yield 5; return 'success'; // , } foreach (genB() as $val) { echo "\n $val"; // 1 5 } $genB()->getReturn(); // 'success'
æåŸ
æåŸ -äžäœäºææ§ãç¶æããªããassertïŒïŒé¢æ°ãæ¹åããŸãã ããã«ãããäœæ¥ã³ãŒãã§ãŒãã³ã¹ãã¢ãµãŒã·ã§ã³ã䜿çšã§ããã¹ããŒãã¡ã³ãã®åŠçäžã«ãšã©ãŒãçºçãããšãã«ã«ã¹ã¿ã äŸå€ãçæããæ©èœããµããŒãããŸããããã¯éçºäžã«åœ¹ç«ã¡ãŸãã
assertïŒïŒé¢æ°ã¯ãPHP 7ã®èšèªæ§æäœã«ãªããŸãããã¯ã¬ãŒã ã¯ããããã°ç®çã®éçºããã³ãã¹ãäžã«ã®ã¿äœ¿çšããŠãã ããã ãã®åäœãèšå®ããã«ã¯ã2ã€ã®ãã£ã¬ã¯ãã£ãã䜿çšããå¿ èŠããããŸãã
- zend.assertions
1ïŒã³ãŒããçæããŠå®è¡ããïŒéçºã¢ãŒãïŒïŒããã©ã«ãå€ïŒ
0ïŒã³ãŒããçæããŸãããå®è¡æã«ãã€ãã¹ããŸã
-1ïŒã³ãŒããçæããããŒãã³ã¹ãã®ã³ãŒãã«ããŸãïŒäœæ¥ã³ãŒãã¢ãŒãïŒ
- assert.exception
1ïŒå¯Ÿå¿ããäŸå€ãªããžã§ã¯ããäœæãããããã®ãããªãªããžã§ã¯ããäœæãããŠããªãå Žåã¯AssertionErrorãªããžã§ã¯ããçæããããšã«ãããã¢ãµãŒã·ã§ã³ãšã©ãŒã«ãã£ãŠçæãããŸã
0ïŒäžèšã®Throwableã䜿çšãŸãã¯çæããŸããããã®ãªããžã§ã¯ãã«åºã¥ããŠèŠåã®ã¿ãçæãããããã䜿çšããŠäŸå€ã¯ã¹ããŒãããŸããïŒPHP 5äºæã®åäœïŒ
PHP 5ããPHP 7ã«ç§»è¡ããæºåããã
PHPããŒãžã§ã³7ã®ç»å Žã«ãããå»æ¢ãããããŸãã¯ãã°ããã®éãã§ã«äžèŠã§ãããšèããããŠããæ©èœãå€æŽ/æŽæ°ãããã«ã¯åé€ããããšãã§ããŸããã ãã®ãããªå€æŽã¯ãå€ãã¢ããªã±ãŒã·ã§ã³ãšã®åŸæ¹äºææ§ã®åé¡ã«ã€ãªããå¯èœæ§ããããŸãã
ãã®ãããªããŒãžã§ã³ã衚瀺ããããšãã«çºçããå¥ã®åé¡ã¯ãéèŠãªã©ã€ãã©ãªãšãã¬ãŒã ã¯ãŒã¯ãæ°ãããªãªãŒã¹ãšäºææ§ã®ããæŽæ°ããã°ã©ã ãæããªãå¯èœæ§ãããããšã§ãã PHPéçºããŒã ã¯ãæ°ããããŒãžã§ã³ãžã®ç§»è¡ã«ãããæéãã§ããã ãçããªãããã«ãäžäœäºææ§ãç¶æããªããå¯èœãªéãå€æŽãå ããããšããŸããã æ¯èŒçæ°ããã¿ã€ã ãªãŒã«æŽæ°ãããã¢ããªã±ãŒã·ã§ã³ã¯ããããã7çªç®ã®ããŒãžã§ã³ã«ç°¡åã«ç§»è¡ã§ããŸãããå€ãã¢ããªã±ãŒã·ã§ã³ã¯ãã©ã³ã¹ã®ãšãã決å®ãå¿ èŠã§ããååŸããæ©èœã«è²»ãããåŽåããŸãã¯ãŸã£ããæŽæ°ããªãæ¹ãããã§ãããã
ã»ãšãã©ã®åé¡ã¯å°ãããç°¡åã«ä¿®æ£ã§ããŸãããä»ã®åé¡ã¯ããå€ãã®æéãšåŽåãå¿ èŠãšããå ŽåããããŸãã äžè¬ã«ãPHP 7ãã€ã³ã¹ããŒã«ããåã«ã¬ã¬ã·ãŒé¢æ°ã®äœ¿çšã«é¢ããèŠåã衚瀺ãããå Žåã¯ãä¿®æ£ããããŸã§ã¢ããªã±ãŒã·ã§ã³ã®å®è¡ãåæ¢ãããšã©ãŒã¡ãã»ãŒãžã衚瀺ãããå¯èœæ§ãé«ããªããŸãã
èŠåãããŸããããïŒ
å€ãSAPIãšæ¡åŒµæ©èœ
ããã«éèŠãªã®ã¯ãmysqlæ¡åŒµæ©èœãªã©ã®å€ããŠäžå¿ èŠãªSAPIãåé€ããããšããäºå®ã§ãïŒãã ãããã䜿çšããªãã®ã§ããïŒïŒã åé€ãããæ¡åŒµæ©èœãšæ©èœã®å®å šãªãªã¹ãã¯ã ãã¡ããšãã¡ããã芧ãã ããã
ä»ã®æ¡åŒµæ©èœãšSAPIãPHP 7ã«ç§»æ€ãããŸããã
å€ãã®å€ãSAPIãšæ¡åŒµæ©èœãPHP 7ããåé€ãããŸãããéå±ããããšã¯ãªããšèããŠããŸãã
åäžå€æ°èšè¿°æ§æ
ãã®æŽæ°ã«ãããå¯å€å€æ°æ§é ã®äžè²«æ§ã®éšåã«ããã€ãã®å€æŽãå°å ¥ãããŸããã ããã«ãããå€æ°ã䜿çšããããé«åºŠãªåŒã䜿çšã§ããããã«ãªããŸããããã«ããã以äžã«ç€ºãããã«ãã³ãŒãã®åäœãå€æŽãããå ŽåããããŸãã
// // $$foo['bar']['baz'] ${$foo['bar']['baz']} ($$foo)['bar']['baz'] $foo->$bar['baz'] $foo->{$bar['baz']} ($foo->$bar)['baz'] $foo->$bar['baz']() $foo->{$bar['baz']}() ($foo->$bar)['baz']() Foo::$bar['baz']() Foo::{$bar['baz']}() (Foo::$bar)['baz']()
ããã«ããããã®æ¹æ³ã§å€æ°ã«ã¢ã¯ã»ã¹ããã¢ããªã±ãŒã·ã§ã³ã®åäœãå€æŽãããŸãã äžæ¹ã次ã®ãããªããªãã¯ãäœæã§ããŸãã
// () foo()(); // Calls the return of foo() $foo->bar()(); //IIFE (Immediately-invoked function expression ) JavaScript (function() { // })(); // :: $foo::$bar::$baz
å€ãã¹ã¿ã€ã«ã®ã¿ã°ãåé€ãããŸãã
éããã¿ã°ãŸãã¯éããã¿ã°ãåé€ãããããããäžæ£ç¢º
<ïŒ ...ïŒ >ã<ïŒ = ...ïŒ >ã<script language = "php"> ... </ script>
ããããæ£ãããã®ã«çœ®ãæããã®ã¯ç°¡åã§ãããæè¿ã®äœ¿çšã¯å°ãå¥åŠã«èŠããŸãããïŒ
ã¯ã©ã¹ãã€ã³ã¿ãŒãã§ãŒã¹ãç¹æ§ã®ç¡å¹ãªåå
æ»ãå€ã®åããã©ã¡ãŒã¿ãŒã®åãªã©ã®è¿œå ã®çµæãšããŠãã¯ã©ã¹ãã€ã³ã¿ãŒãã§ã€ã¹ãããã³ç¹æ§ã«ãããã®ååãä»ããããšã¯ã§ããªããªããŸããã
- ããŒã«
- int
- æµ®ã
- ã²ã
- ãã«
- æ¬åœ
- åœ
ãã®ãããªåœåã¯ãæ¢åã®ã¢ããªã±ãŒã·ã§ã³ããã³ã©ã€ãã©ãªã®èª€ã£ãåäœã«ã€ãªããå¯èœæ§ããããŸãããç°¡åã«ä¿®æ£ã§ããŸãã 次ã®ååããå°æ¥ã®ããã«äºçŽãããŠãããããäžèšã®å質ã§ã¯æãŸãããããŸããã
- è³æº
- 察象
- æ··åãã
- æ°å€
ãããã®åèªãååãšããŠäœ¿çšããªãã§ãã ãããåŸã§æéãç¯çŽã§ããŸãã
éäºææ§ã®åå ãšãªãå€æŽã®å®å šãªãªã¹ãã¯ã ããã«ãããŸã ã
php7ccã䜿çšããããšãã§ããŸã ããã®ããŒã«ã¯ã³ãŒãããã§ãã¯ããPHP 7ã«åãæ¿ãããšãã«çºçããå¯èœæ§ã®ããæœåšçãªåé¡ã衚瀺ããŸãã
ããããPHP 7ãã€ã³ã¹ããŒã«ããŠèªåã§ç¢ºèªãããããè¯ãæ¹æ³ã¯ãããŸããã
æœåšçãªPHP 7ã®äºææ§ã®åé¡
PHP 7ã€ã³ãã©ã¹ãã©ã¯ãã£ã®äºææ§
å€ãã®ãã¹ãã£ã³ã°ãµãŒãã¹ãPHP 7ã®ãµããŒããè¿œå ããŸãããããã¯ãå ±æãã¹ãã£ã³ã°ãããã€ããŒã«ãšã£ãŠæå ±ã§ããçç£æ§ãåäžãããšãããŒããŠã§ã¢ãæŽæ°ããã«ã¯ã©ã€ã¢ã³ãWebãµã€ãã®æ°ãå¢ãããã©ã³ãã³ã°ã³ã¹ããšåçãåæžã§ããããã§ãã ã¯ã©ã€ã¢ã³ãã«é¢ããŠã¯ããããã®æ¡ä»¶ã§ã®çç£æ§ã®æ¥æ¿ãªå¢å ãæåŸ ãã¹ãã§ã¯ãªããççŽã«èšã£ãŠãããã©ãŒãã³ã¹æåã¢ããªã±ãŒã·ã§ã³ã®å Žåãå ±æãã¹ãã£ã³ã°ã¯ãããã®å Žåããªãã·ã§ã³ã§ã¯ãããŸããã
äžæ¹ããã©ã€ããŒãä»®æ³ãµãŒããŒãŸãã¯å°çšãµãŒããŒãæäŸãããµãŒãã¹ã¯ãããã©ãŒãã³ã¹ã®åäžã®æ©æµãåããŸãã Herokuãªã©ã®äžéšã®PaaSãµãŒãã¹ã¯ ãPHP 7ãé·ãéãµããŒãããŠããŸãããAWS BeanstalkãOracle OpenShiftãªã©ã®PaaSãµãŒãã¹ã¯é ããŠããŸãã PaaSãããã€ããŒã®Webãµã€ãã§ãPHP 7ããµããŒããããŠããããè¿ãå°æ¥ã«èšç»ãããŠãããã確èªããŠãã ããã
IaaSãããã€ããŒã䜿çšãããšãããŒããŠã§ã¢ãå¶åŸ¡ããŠPHP 7ãã€ã³ã¹ããŒã«ïŒãŸãã¯ãå¿ èŠã«å¿ããŠã³ã³ãã€ã«ïŒã§ããŸãã PHP 7ããã±ãŒãžã¯ãã»ãšãã©ã®IaaSç°å¢ã§ãã§ã«å©çšå¯èœã§ãã
PHP 7ãšã®ãœãããŠã§ã¢äºææ§
ã€ã³ãã©ã¹ãã©ã¯ãã£ã®äºææ§ã«å ããŠãæœåšçãªãœãããŠã§ã¢äºææ§ã®åé¡ã«ã泚æããå¿ èŠããããŸãã WordPressãJoomlaãDrupalãªã©ã®æåãªCMSã¯ãæ¢ã«PHP 7ã®ãµããŒããè¿œå ããŠããŸããSymfonyãLaravelãªã©ã®äž»èŠãªãã¬ãŒã ã¯ãŒã¯ããããå®è¡ããŠããŸãã
ãããã泚æããæãæ¥ãŸããã ãã®ãµããŒãã¯ãCMSãŸãã¯ãã¬ãŒã ã¯ãŒã¯ãåç §ããã¢ããªã³ããã©ã°ã€ã³ãããã±ãŒãžãªã©ã®åœ¢åŒã®ãµãŒãããŒãã£ã³ãŒãã«ã¯é©çšãããŸããã åé¡ããããããããŸãããããªãã®ä»äºã¯ããã¹ãŠãPHP 7ã§åäœããæºåãã§ããŠããããšã確èªããããšã§ãã
ãµããŒããããŠããã¢ã¯ãã£ããªãªããžããªã®å Žåãããã¯åé¡ã«ãªããŸããã ãã ããPHP 7ããµããŒãããªãæŸæ£ããããªããžããªã§ã¯ãã¢ããªã±ãŒã·ã§ã³å šäœã䜿çšã§ããªããªãå¯èœæ§ããããŸãã
å°æ¥ã®PHP
PHP 7ã¯å»æ¢ãããã³ãŒããåé€ããæ°æ©èœãšå°æ¥ã®ããã©ãŒãã³ã¹ã®æ¹åã«éä¿¡å·ãäžããŸããã ããã«ãPHPã¯ããã«ããã©ãŒãã³ã¹ã®æé©åãååŸããã¯ãã§ãã 以åã®ããŒãžã§ã³ãšã®äžäœäºææ§ã¯éšåçã«å€±ãããŠããŸãããçºçããåé¡ã®ã»ãšãã©ã¯ç°¡åã«è§£æ±ºã§ããŸãã
ã©ã€ãã©ãªãšãã¬ãŒã ã¯ãŒã¯ã¯PHP 7ã«ç§»è¡ããæ°ããããŒãžã§ã³ãç»å ŽããŸãã 7ã€ãè©ŠããŠçµæãè©äŸ¡ããããšããå§ãããŸãã ããªãã®ã¢ããªã±ãŒã·ã§ã³ã¯æ¢ã«æ°ããããŒãžã§ã³ãšäºææ§ããããPHP 7ã§äœ¿çšããæºåãã§ããŠããã®ãããããŸããã