1. PHPã®æŠèŠãšãã®ç¹æ§
äžçäžã®Webã¢ããªã±ãŒã·ã§ã³ãWebãµã€ãéçºã«åºã䜿çšãããŠããPHPãããã§ã¯PHPã®æŠèŠãããã®ç¹æ§ããããŠWebéçºã«ããã匷ã¿ã匱ç¹ã«ã€ããŠæ·±ãæãäžããŠã¿ãããšæããŸãã
ãããã®ç¥èã身ã«ã€ããããšã§ãPHPã®å§åçãªå¯èœæ§ãããæ·±ãç解ããããªãã®Webéçºæ¥çã§ã®çåçã確å®ã«é«ããããšãã§ããŸãã
1.1 PHPãšã¯äœãïŒ
PHPã¯ãWebã¢ããªã±ãŒã·ã§ã³ãWebãµã€ãéçºã«äœ¿çšãããããã°ã©ãã³ã°èšèªã§ãããç¹ã«WebããŒãžã«åããä»ãå ããããšãåŸæãšããèšèªã§ãããŠã§ãéçºã«ç¹åããã·ã³ãã«ãªæ§æãç¹åŸŽã§ãå€ãã®äººã ãæ¹ãã€ããŠããŸãã
èŠããããã·ã³ã¿ãã¯ã¹ãšãè±å¯ãªæ å ±éããPHPåŠç¿è ã«ãšã£ãŠã¯å€§ããªã¡ãªãããšãªã£ãŠããŸãããããŠããã¡ããPHPã®äœ¿åœã¯ããŠã§ãããŒãžãããé åçã§åçãªãã®ã«ããããšã§ãã
1.2 PHPã®ç¹æ§
PHPã¯ããWebéçºã«ç¹åããèšèªãã§ããããåçåä»ãèšèªãã§ãããšãã®ç¹æ§ãè©ãããŸããã€ãŸããæ¯èŒççãã³ãŒãã§é«åºŠãªæ©èœãå®çŸããããšãå¯èœã§ããŸããæ§ã ãªããŒã¿åãæè»ã«æ±ãããšãã§ããã®ã§ãã
ç¹ã«PHPã®äººæ°ã®çç±ãšããŠã¯ã匷åãªWebãã¬ãŒã ã¯ãŒã¯ã®ååšãæããããŸããããšãã°ãLaravelãSymfonyãªã©ãå€ãã®ãã¬ãŒã ã¯ãŒã¯ãæäŸãããŠãããéçºã®å¹çåã«å€§ãã«è²¢ç®ããŠããŸãã
1.3 PHPããŠã§ãéçºã«éžã°ããçç±
ããã§ã¯ããªãPHPããŠã§ãéçºã®ãã£ãŒã«ãã§åºãéžã°ããŠããã®ã§ãããããäžã€ç®ã®çç±ãšããŠãPHPã®åŠç¿ã³ã¹ãã®äœããæããããŸããæ§æãã·ã³ãã«ã§ç解ãããããããåå¿è ã§ãæ¯èŒç容æã«åŠç¿ããããšãã§ããŸãã
ãŸããäžçäžã§åºã䜿ãããŠããèšèªã§ãããããã€ã³ã¿ãŒãããäžã«ã¯å€ãã®ãã¥ãŒããªã¢ã«ã解説èšäºãååšããããããå©çšããŠèªå·±åŠç¿ãé²ããããšãå¯èœã§ãã
1.4 PHPã®åŒ±ç¹ãšå¯Ÿç
ããããäžæ¹ã§PHPãå®ç§ãªèšèªã§ã¯ãããŸãããç¹ã«ãWeb以å€ã®éçºã«ã¯åããŠããªããšèšãããããšãå€ãã§ãããŸããã»ãã¥ãªãã£ãããçããšããè©äŸ¡ãååšããŸãã
ãŸããPHPã¯èªç±åºŠãé«ããããšãããã¡ãªããããããŸããããã¯ãã³ãŒããèŠã¥ãããªã£ãããäºæ³ããªãåäœãããå¯èœæ§ããããšãããªã¹ã¯ããããããŸãã
ãããã®åŒ±ç¹ã«å¯ŸããŠã¯ãéŠå°Ÿè¯ããã¬ãŒã ã¯ãŒã¯ã䜿çšããããšããããŠé©åãªã»ãã¥ãªãã£èšèšãšã³ãŒãã£ã³ã°èŠçŽã®éµå®ã«ããã倧ãã«å¯Ÿçããããšãå¯èœã§ããããã«ããPHPã¯ãããã«ç¢ºããªéçºçä¿¡é Œæ§ãæã€ããšãšãªããŸãã
2. PHPã«ããWebéçºã®å¯èœæ§
PHPã¯ãWebéçºã®äžçãé²åãããããã°ã©ãã³ã°èšèªãšããŠåºãèªèãããŠããŸãããã®å¯èœæ§ã¯ç¡é倧ã§ãããŒã¿é§ååã®ãã€ãããã¯ãªWebããŒãžã®å¶äœãããããŒã¿ããŒã¹ãšã®é£æºãWebã¢ããªã±ãŒã·ã§ã³éçºãŸã§å€æ¹é¢ã«åã³ãŸãã
ç¹ã«ãWebéçºã«ç¹åããèšèªã§ãããããç解ããããã·ã³ãã«ãªæ§æãšäœãåŠç¿ã³ã¹ããé åã§ãã
ãããããã®äžæ¹ã§PHPã«ã¯ã»ãã¥ãªãã£ãããçããèªç±åºŠãé«ããããšãã£ããã¡ãªãããååšããŸããããã§ãããã®å¯èœæ§ãšå©ç¹ãç解ã掻çšããããšã§ããããã®èª²é¡ã解決å¯èœã§ãã
2.1 ãã€ãããã¯ãªWebããŒãžã®å¶äœ
PHPã®æ倧ã®ç¹é·ã®äžã€ã¯ããŠã§ãããŒãžã«ãåãããäžããããšãã§ããç¹ã§ããåçåä»ãèšèªã§ããPHPã¯ãæ¢åã®éçHTMLããŒãžã«ã¹ã¯ãªãããåã蟌ãããšãå¯èœã§ãããŒãžã®ããŒãæã«ãµãŒããŒäžã§å®è¡ãããåçã³ã³ãã³ããçæããŸãã
ããã«ããããŠãŒã¶ãŒã®è¡åã«å¯Ÿå¿ããã«ã¹ã¿ã ã³ã³ãã³ããæäŸããããæéãå Žæã«ãã£ãŠå€ããæ å ±ããªã¢ã«ã¿ã€ã ã«åæ ããçãéåžžã«ãã€ãããã¯ãªWebããŒãžãå¶äœããããšãå¯èœãšãªããŸãã
æŽã«ãPHPã®åŒ·åãªãã¬ãŒã ã¯ãŒã¯ã掻çšãããã°ãããçæéã§é«å質ãªWebããŒãžãå¶äœããããšãå¯èœã§ãã
2.2 ããŒã¿ããŒã¹ãšã®é£æº
PHPã¯ããŒã¿ããŒã¹ãšã®é£æºã容æã§ãç¹ã«MySQLãªã©ã®äžè¬çãªããŒã¿ããŒã¹ç®¡çã·ã¹ãã ãšã®çžäºäœçšãéåžžã«ã¹ã ãŒãºã§ãããŠãŒã¶ãŒæ å ±ã®ç®¡çããååæ å ±ã®ååŸãèšäºã®æ€çŽ¢ãªã©ãWebãµã€ãéå¶ã«ã¯ããŒã¿ããŒã¹ã¯äžå¯æ¬ ã§ãããã§ãPHPã®åã掻ããŸãã
SQLæãå®è¡ããŠããŒã¿ããŒã¹ããæ å ±ãååŸãããã®æ å ±ãå ã«åçãªWebã³ã³ãã³ããçæããããšãå¯èœã§ãã
ãã¬ãŒã ã¯ãŒã¯ã䜿çšå ŽåãORMïŒObject-Relational MappingïŒã®æ©èœã䜿çšããããšã§ãSQLæãçŽæ¥æžãå¿ èŠãªãããŒã¿ããŒã¹ãšã®é£æºãè¡ãããšãã§ããéçºé床ãæ Œæ®µã«åäžãããããšãã§ããŸãã
2.3 PHPã«ããWebã¢ããªã±ãŒã·ã§ã³éçº
PHPã«ããWebã¢ããªã±ãŒã·ã§ã³éçºã¯ããŠãŒã¶ããªãã£ãšå¹çæ§ã®é¢ã§éåžžã«åªãããã®ãšãªãããŸãããŠãŒã¶ã®éèŠã«å¿ããæ©èœéçºããçæéã§ã®ãã«æ©èœWebã¢ããªã±ãŒã·ã§ã³ã®æ§ç¯ãå¯èœã§ããã®ã¹ã±ãŒã©ããªãã£ã¯åå¥ã®äŒæ¥ãçµç¹ã®ããžãã¹ã¢ãã«ã«éåžžã«ãããããŸãã
ããã«ãPHPã¯å€ãã®ãã¬ãŒã ã¯ãŒã¯ãå©çšããããšã§ãMVCïŒModel-View-ControllerïŒã®ãããªèšèšååã«åºã¥ãæŽçãããã³ãŒãæ§æãå®çŸããä¿å®æ§ã»æ¡åŒµæ§ãé«ãããšããã¡ãªããããããŸãã
ãã®ãããäŒæ¥ã®ã³ã¢ã·ã¹ãã ããå°èŠæš¡ãªå人éçºãŸã§ãåçš®Webã¢ããªã±ãŒã·ã§ã³ã«é©çšå¯èœãªãã¬ãã·ãã«ãªèšèªãšããŠã®æŽ»çšãæåŸ ã§ããŸãã
2.4 å®éçãªPHPã®äœ¿çšäŸ
å®éçãªPHPã®äœ¿çšäŸãšããŠã¯ã瀟å ã®æ å ±å ±æã·ã¹ãã ãECãµã€ãã®ååãããžã¡ã³ããããã°ãµã€ãã®èšäºç®¡çãªã©ãæããããŸãããããã®ããŸããŸãªWebã·ã¹ãã ã¯ãPHPã®ããŒã¿ããŒã¹é£æºæ©èœãšåçãªwebããŒãžçææ©èœã«ãã£ãŠãå¹ççã«éçšããããšãã§ããŸãã
ãŸããSNSã®ãããªãŠãŒã¶éã®ã³ãã¥ãã±ãŒã·ã§ã³ãéèŠãããµãŒãã¹ã«ãšã£ãŠããPHPã¯å¿ èŠãªæ©èœãå¹çè¯ãéçºã§ãããããå€ãã®ãµãŒãã¹ã§æ¡çšãããŠããŸãã
ããã«ãè¿å¹Žã¯WordPressãªã©ã®CMSïŒContent Management SystemïŒã®æ®åã«ãããå人ã§ãPHPã掻çšããWebãµã€ãæ§ç¯ã容æã«ãªã£ãŠãããæ°è»œã«PHPã®å¯èœæ§ã«è§Šããããšãå¯èœãšãªããŸããã
3. PHPãšä»ã®èšèªãšã®æ¯èŒ
Webéçºã®äžçã§ã¯ãéžæãã¹ãèšèªã¯ãã äžã€ã ãã§ã¯ãããŸãããPHPãJavaãPythonãJavaScriptãªã©ãæ§ã ãªèšèªãååšãããããããç¹åããé åãåªããç¹æ§ãæã£ãŠããŸãããã®èŠåºãã§ã¯ãPHPãšä»ã®äººæ°èšèªãšã®æ¯èŒãéããŠããªãPHPãå€ãã®éçºè ã«éžã°ããã®ãããã®çç±ãæ¢ããŸãããã
ãã®æ¯èŒã¯ããå šãŠã®èšèªãçããæ±ããããããšãç®æãããªãã¹ãå ¬å¹³ãªèŠç¹ãã芳å¯ããŸããããããã®èšèªãäœã«æé©ã§ãäœãåŸæã§ããã®ããç解ããŠãããŸãããã
å šãŠã®ããã°ã©ãã³ã°èšèªãäžæŠã«ãè¯ãããŸãã¯ãæªãããšã¯èšããŸãããç®çãç¶æ³ã«ãã£ãŠæé©ãªéžæã¯ç°ãªããããå ·äœçãªç¶æ³ã«åºã¥ããæ¯èŒçµæãæäŸããŸãã
3.1 PHP vs Java
Javaã¯äžè¬çã«å€§èŠæš¡ãªãšã³ã¿ãŒãã©ã€ãºã·ã¹ãã éçºãAndroidã¢ããªéçºãªã©ã«ãã䜿çšãããŸããäžæ¹ãPHPã¯æ¬è³ªçã«Webéçºã«ç¹åããèšèªã§ãç¹ã«ãµãŒããŒãµã€ãã®éçºã«åŒ·ã¿ãæã£ãŠããŸãã
Javaã¯éçåä»ãèšèªã§ãå®å šæ§ãšã¹ã±ãŒã©ããªãã£ã«éç¹ã眮ããŠããŸããããã«å¯ŸããŠPHPã¯åçåä»ãèšèªã§ããã¬ãã·ããªãã£ãšç°¡ææ§ãéèŠããŠããŸãã
Javaã¯åŠç¿æ²ç·ãPHPãããæ¥ã§ãããšèšãããŠããŸããããããJavaã®æ¹ãå€æ©èœã§ãããããåºç¯ãªã¢ããªã±ãŒã·ã§ã³éçºã«å¯Ÿå¿ããŠããŸãã
3.2 PHP vs Python
Pythonã¯AIãæ©æ¢°åŠç¿ãããŒã¿åæãšãã£ãåéã§éåžžã«äººæ°ã®ããèšèªã§ããäžæ¹ãPHPã¯äž»ã«Webã¢ããªã±ãŒã·ã§ã³ã®ããã¯ãšã³ãéçºã«äœ¿çšãããŸãã
PHPã¯Pythonãšæ¯èŒãããšããã¬ãŒã ã¯ãŒã¯ãè±å¯ã§ãããWebéçºã«å¯Ÿããçµã¿èŸŒã¿ã®ãµããŒãã匷åã§ããããããPythonã¯ããç°¡æœã§ãèªã¿ãããã·ã³ã¿ãã¯ã¹ãæã€ãšåºãèªèãããŠããŸãã
ãŸããäž¡è ã¯åŠç¿é£æ床ã«ãããŠå€§ããªéãããããŸããPythonã®æ¹ãåå¿è ã«ãšã£ãŠã¯ããããèšèªãšãããŠããŸãããPHPãåŠç¿ã³ã¹ããäœããšè©äŸ¡ãããŠããŸãã
3.3 PHP vs JavaScript
JavaScriptã¯å ã ãã©ãŠã¶å éšã§åäœããããã³ããšã³ãéçºèšèªãšããŠéçºãããŸãããããããNode.jsã®ç»å Žã«ããããµãŒããŒãµã€ãã®éçºã«ãå©çšãããããã«ãªããŸãããäžæ¹ãPHPã¯ãµãŒããŒãµã€ãå°çšã®èšèªã§ãã
PHPãšJavaScriptã®å€§ããªéãã¯ãJavaScriptãããã³ããšã³ããšããã¯ãšã³ãã®äž¡æ¹ã§äœ¿çšã§ããç¹ã§ãããããPHPã¯ããã¯ãšã³ãéçºã«ç¹åããŠããŸãããã®ããããã«ã¹ã¿ãã¯éçºãæãå Žåã¯JavaScriptãåªããŠããŸããããµãŒããŒãµã€ãã«çŠç¹ã眮ãå Žåã¯PHPãå¹ççã§ãã
ãŸããPHPãšJavaScriptã¯ã³ãã¥ããã£ãµã€ãºã«ãããŠå€§ããªéãããããŸããJavaScriptã¯çŸåšãæã人æ°ã®ããããã°ã©ãã³ã°èšèªã®äžã€ã§ãããã³ãã¥ããã£ãéåžžã«æŽ»çºã§ããäžæ¹ãPHPã倧ããªã³ãã¥ããã£ãæã¡ãè±å¯ãªæ å ±ãšãµããŒããå©çšå¯èœã§ãã
3.4 èšèªéžæã®ãã€ã³ã
ããã°ã©ãã³ã°èšèªãéžæããéã®ãã€ã³ãã¯ããããžã§ã¯ãã®èŠä»¶ãç°å¢ãç®çã«äŸåããŸãã䜿çšããæè¡ã®é©åããè©äŸ¡ããããã«ã¯ãããã解決ãã¹ãåé¡ã«ã©ãã ãé©åããŠããããæ€èšŒããããšãå¿ èŠã§ãã
äŸãã°ãWebéçºã«ç¹åããŠãããããšãã£ãŠPHPãå šãŠã®Webéçºãããžã§ã¯ãã«æé©ãªéžæãšã¯éããŸãããéçºããŒã ã®ã¹ãã«ã»ããããããžã§ã¯ãã®èŠæš¡ãæåŸ ãããããã©ãŒãã³ã¹ãªã©ããã®ä»ã®ããŸããŸãªèŠçŽ ãèæ ®ããå¿ èŠããããŸãã
ã€ãŸããæçµçãªéžæã¯ãããªãã解決ãããç¹å®ã®èª²é¡ãç®æšã«å¯ŸããŠãã©ã®èšèªãæãé©åã«å¯Ÿå¿ã§ããããè©äŸ¡ããããšãéèŠã§ãã
4. PHPéçºã®æºåãšç°å¢æ§ç¯
4.1 PHPã®ããŠã³ããŒããšã€ã³ã¹ããŒã«
PHPã®äœ¿çšãå§ããããã«ã¯ããŸãPHPèªäœãããŠã³ããŒãããŠã€ã³ã¹ããŒã«ããå¿ èŠããããŸããPHPå ¬åŒãµã€ãããææ°ããŒãžã§ã³ãããŠã³ããŒãããOSã«åãããã€ã³ã¹ããŒã«ã¬ã€ãã«åŸãèšå®ãè¡ããŸãã
ã€ã³ã¹ããŒã«ã®éã«ã¯ãåçš®ããã±ãŒãžã®æºåãå¿ èŠã§ãããããã®ããã±ãŒãžã«ã¯ApacheãMySQLãªã©ãå«ãŸããŸãã
以äžã®æé ãèžãããšã§ãåºæ¬çãªPHPã®éçºç°å¢ãæ§ç¯ããããšãå¯èœã§ãã
4.2 éçºç°å¢ã®èšå®
éçºç°å¢ã®èšå®ã«ã€ããŠã§ãããååŠè ã¯XAMPPã䜿çšããããšã§ãçŽ æ©ãç°å¢èšå®ãæžãŸããããšãã§ããŸããXAMPPã¯ApacheãMariaDBãPHPãPerlãäžç·ã«ãªã£ãŠãããããå¿ èŠãªç°å¢ãäžã€ã§æããããŸãã
次ã«ãPHPã®èšå®ãè¡ãããã«php.iniãã¡ã€ã«ãç·šéããŸããããã§ã¯ããšã©ãŒã¬ãã«ããããã°ãªãã·ã§ã³ãæ¡åŒµæ©èœã®æå¹åãªã©ãèšå®ããŸãã
以äžã®æé ã«ãããããŒã«ã«ã§ã®PHPéçºç°å¢ãæºåã§ããŸãã
4.3 PHPã®éçºçšããŒã«
PHPã®éçºã«ã¯ãIDEïŒIntegrated Development EnvironmentïŒã䜿çšããŸãã匷åãªãšãã£ã¿æ©èœããããã°ãã³ãŒãè£å®æ©èœãªã©ãå€æ°ã®äŸ¿å©ãªæ©èœãæã€IDEã¯ãPHPéçºã®å¹çãšå質ãåäžãããŸããVS Code ãPHPStormãªã©ãæåã§ãã
ãŸããããŒãžã§ã³ç®¡çã®ããã®ããŒã«ã§ããGitãéèŠãªããŒã«ã®äžã€ã§ããè€æ°ã®éçºè ãäžç·ã«äœæ¥ãè¡ãéããå€æŽå±¥æŽã远跡ããããã«å¿ èŠã§ãã
ãããã®ããŒã«ãäžæã䜿ãããšã§ãããã¹ã ãŒãºãã€å¹ççãªéçºãå¯èœã«ãªããŸãã
4.4 ãããã°æ¹æ³ã®çŽ¹ä»
PHPã®ãããã°æ¹æ³ã«ã€ããŠèª¬æããŸããäžè¬çã«PHPã§ã¯var_dump()é¢æ°ã䜿ã£ãŠå€æ°ã®äžèº«ã確èªãããããšã©ãŒãã°ã確èªããŠãããã°ãè¡ããŸãã
ãŸããXdebugã䜿çšãããšããã¬ãŒã¯ãã€ã³ããèšçœ®ããŠã³ãŒãã®æåãã¹ããããã€ã¹ãããã§è¿œããå€æ°ã®å€ãªã©ããªã¢ã«ã¿ã€ã ã«èŠ³æž¬ããããšãã§ããŸãã
ãããã®ãããã°æ¹æ³ãç解ããäžæã«çšããããšã§ãããæ£ç¢ºãªåäœãããã³ãŒããäœæããããšãã§ããŸãã
5. PHPã®åºæ¬çãªã³ãŒããšæ§æ
PHPã¯éåžžã«æ±ããããèšèªã§ããã®åºæ¬çãªã³ãŒããšæ§æãç解ããããšã¯Webã¢ããªã±ãŒã·ã§ã³ããŠã§ããµã€ãã®éçºã«ãããæåãžã®éµãšãªããŸãã
ããããã玹ä»ããã³ãŒãã£ã³ã°ã«ãŒã«ãå¶åŸ¡æ§é ãé¢æ°ã®å®çŸ©æ¹æ³ããããŠãšã©ãŒãã³ããªã³ã°ã«ã€ããŠãåºæ¬çãªç¥èã身ã«ã€ããŠãããŸãããã
ãããã®æ§æãšã«ãŒã«ãç解ãç¿åŸããã°ãããªãèªèº«ã§åçãªWebããŒãžãå®è£ ãããŠãŒã¶ãŒãšã®å 容ããªã¢ã«ã¿ã€ã ã§äº€æããããšãå¯èœãšãªããŸãã
5.1 PHPã®åºæ¬çãªã³ãŒãã£ã³ã°ã«ãŒã«
PHPã®åºæ¬çãªã³ãŒãã£ã³ã°ã«ãŒã«ã¯éåžžã«çŽèŠ³çã§ããããåŠç¿ã®æ·å± ãäžããŠããŸããPHPã§ã¯å€æ°åã«ã$èšå·ãå é ã«ã€ããã«ãŒã«ããããŸãããŸããã³ãŒãã®è¡æ«ã«ã¯ã»ãã³ãã³(;)ã䜿çšããŠçµããããŸãã
ãŸããPHPã®ã³ãŒãã¯<?php ããã³ ?>ã¿ã°ã§å²ãŸããŠããŸãããããã®ã¿ã°ããªããšããã®ã³ãŒãã¯PHPãšããŠèªèãããŸããã
ããã«ãPHPã§ã¯åçŽãªif-elseãswitch-caseãªã©ã®ãããã¯ãå®çŸ©ããéã«ãäžæ¬åŒ§ ( { } ) ã®äœ¿çšãå¿ é ã§ãã
5.2 å¶åŸ¡æ§é ãšã«ãŒã
PHPã¯å€ãã®å¶åŸ¡æ§é ãšã«ãŒããçšæãããŠããŸãããã®æããäŸãif-elseå¶åŸ¡æ§é ã§ãæ¡ä»¶ãæºããããæã®ã¿ç¹å®ã®ã³ãŒããå®è¡ããããã«äœ¿çšãããŸãã
ã«ãŒãã«ã€ããŠã¯ãforãwhile, foreachãªã©ã®ã«ãŒãæ§é ãååšããŸãããããã®ã«ãŒãã¯æå®ãããæ¡ä»¶ãçã®éããŸãã¯é åã®ãã¹ãŠã®èŠçŽ ã«å¯ŸããŠãåŠçãç¹°ãè¿ããŸãã
ãããã®å¶åŸ¡æ§é ãšã«ãŒããé§äœ¿ããããšã§ãPHPã¯éåžžã«åŒ·åãã€æè»ãªããã°ã©ãã³ã°èšèªã«ãªã£ãŠããŸãã
5.3 é¢æ°ãšã¯ã©ã¹
ç¡æ°ã®ã¿ã¹ã¯ãå¹ççã«ç®¡çããåå©çšå¯èœãªã³ãŒããäœæããããã«ãPHPã§ã¯é¢æ°ãšã¯ã©ã¹ãå®çŸ©ã§ããŸããé¢æ°ã¯ç¹å®ã®ã¿ã¹ã¯ãå®è¡ããã³ãŒãã®ãŸãšãŸãã§ãäžåºŠå®çŸ©ããã°äœåºŠã§ãåŒã³åºãããšãã§ããŸãã
äžæ¹ãã¯ã©ã¹ã¯PHPã®ãªããžã§ã¯ãæåããã°ã©ãã³ã°ã«ãããæãéèŠãªæŠå¿µã§ãé¢é£ããé¢æ°ïŒã¡ãœãããšåŒã°ããïŒãšå€æ°ïŒããããã£ãšåŒã°ããïŒãã²ãšãŸãšãã«ããŠããŸãã
ãã®ãããªé¢æ°ãšã¯ã©ã¹ã®äœ¿çšã«ãããPHPã§ã¯ã³ãŒãã®åå©çšæ§ãšç¶æ管çæ§ãé«ãŸããŸãã
5.4 ãšã©ãŒãã³ããªã³ã°
ãšã©ãŒãã³ããªã³ã°ã¯ä»»æã®ããã°ã©ãã³ã°èšèªã«ãããéèŠãªåŽé¢ã®äžã€ã§ãPHPãäŸå€ã§ã¯ãããŸããããšã©ãŒãçºçããå Žåã®åŠçãé©åã«è¡ããããPHPã«ã¯ãšã©ãŒãã³ããªã³ã°æ©èœãçšæãããŠããŸãã
åºæ¬çã«ãPHPã§ã¯ãšã©ãŒãã³ããªã³ã°ã®ããã«try-catchãããã¯ã䜿çšããŸããå ·äœçã«ã¯ããšã©ãŒãçºçããå¯èœæ§ã®ããã³ãŒããtryãããã¯å ã«èšè¿°ãããšã©ãŒãçºçããå Žåã®åŠçãcatchãããã¯å ã§è¡ããŸãã
ãã®ããã«ããŠåŠçããããšã§ããšã©ãŒãçºçããŠãé©åã«å¯Ÿå¿ããã¢ããªã±ãŒã·ã§ã³ãå®å®çšŒåãããããšãå¯èœã«ãªããŸãã
6. PHPã§ææŠããããããžã§ã¯ã
PHPãåŠã¶åæ©ãç®æšã¯å€æ§ã§ããããŸã§ã®åŠç¿ã掻ãããŠèªåã ãã®ãããžã§ã¯ããäœãäžããããšèãã人ãå°ãªããããŸããã以äžã§ã¯ãPHPã§ææŠã§ãããããžã§ã¯ãã®äžéšã玹ä»ããŸãã
6.1 åçŽãªWebãµã€ãã®æ§ç¯
ãåçåä»ãèšèªãã§ããPHPã䜿çšããã°ãåçŽãªHTMLããŒãžããã©ã³ãã£ã³ã°ããŒãžãããã°ãäŒæ¥æ å ±ãµã€ããšãã£ãWebãµã€ããŸã§ãå¹ åºãçš®é¡ã®Webãµã€ããæ§ç¯ããããšãå¯èœã§ããPHPã¯Webéçºã«å¯Ÿãã匷åãªæ¯æŽæ©èœãæäŸããŠãããããèªåèªèº«ã®ã¢ã€ãã¢ãå ·çŸåããã«ã¯æé©ãªèšèªãšèšããŸãã
æŽã«ãPHPãåŠã¶ããšã§HTMLãCSSãJavaScriptãªã©ã®åºç€çãªWebæè¡ã身ã«ã€ããããSEO察çãèãããµã€ãéçšãããã¶ã€ã³æ§ã®é«ããµã€ãäœããå¯èœã«ãªãã§ãããã
åå¿è ã«ãåªããææ³ã§ãè±å¯ãªè³æãååšããPHPã䜿ãããªãã°ãããŸããŸãªWebãµã€ããæ§ç¯ã§ããŸãã
6.2 ãŠãŒã¶ãŒèªèšŒä»ãWebã¢ããªã±ãŒã·ã§ã³ã®éçº
PHPã䜿ããšããŠãŒã¶ãŒèªèšŒãæã€Webã¢ããªã±ãŒã·ã§ã³ã®éçºãå¯èœã§ãããã°ã€ã³ãç»é²ãªã©ãã»ãã¥ãªãã£é¢ã§ã®å¯Ÿçãå¿ èŠãªã¢ããªã±ãŒã·ã§ã³éçºã«ããPHPã¯æå¹ãªããŒã«ãšèšããŸãã
ããŒã¿ããŒã¹ãšé£æºãããŠæ å ±ã管çããå Žé¢ã§ããPHPãªãã°MySQLãPostgreSQLãªã©å€ãã®ããŒã¿ããŒã¹ãšã®é£æºãå¯èœã§ãã°ããŒãã«ã§çšããããããŒã¿ããŒã¹ãæ軜ã«æ±ããŸãã
ãŠãŒã¶ãŒã®ãã°ã€ã³ç¶æ ãä¿æããã»ãã·ã§ã³ç®¡çãã¯ãããå®å šã«æ å ±ã管çãããŠãŒã¶ãŒã«ããå®å¿æãçã¿åºãããã®æ©èœãå®è£ ããã«ã¯ãPHPã®åŠç¿ãäžå¯æ¬ ã§ãã
6.3 RESTful APIã®äœæ
PHPã䜿ã£ãè¿œå ã®å¯èœæ§ãšããŠRESTful APIã®äœæããããŸããããã«ãããä»ã®WebãµãŒãã¹ãã¢ããªã±ãŒã·ã§ã³ãšããŒã¿ããããšãããããšãå¯èœã«ãªããŸãã
å€æ©èœãªAPIãäœãããšã§ããã倧èŠæš¡ãªã·ã¹ãã ã«é£æºãããããšãã§ããæäŸãããµãŒãã¹ã®é©çšç¯å²ãåºãããŸããPHPã§APIãäœãããã«ã¯ãHTTPã¡ãœãããç解ãæ°æ®ç±»åã®æäœããã¹ã¿ãŒããå¿ èŠããããŸãã
APIã®äœæã¯äžèŠé£ããããã«æããŸãããç解ããããPHPãçšããã°ããã®é åã«ãææŠããããšãå¯èœã§ãã
6.4 å°æ¥çãªåŠç¿ã®æ¹åæ§ãšå±æ
PHPããã¹ã¿ãŒããã°ãããã³ããšã³ãéçºãããŒã¿ããŒã¹ç®¡çãå«ããå šäœçãªWebéçºãç解ããããã®è¶³ããããšãªããŸãã
çå®ã«ã¹ãã«ã¢ãããéããããŸããŸãªãããžã§ã¯ãã«ææŠããããšã§ãèªåã ãã®ãªãªãžãã«WebãµãŒãã¹ãçã¿åºãããšãå¯èœã«ãªãã§ãããã
ããã«ãå€ãã®åŒ·åãªãã¬ãŒã ã¯ãŒã¯ãCMSãPHPã«å¯Ÿå¿ããŠãããããLaravelãWordPressãªã©ãåŠã¶ããšã§å€çš®å€æ§ãªWebãµãŒãã¹ã®éçºã«æãããšãå¯èœã«ãªããŸãããããã®ããŒã«ã䜿ãããšã§ãããå¹ççãªéçºãæ¢åã®ã·ã¹ãã ã®æ¹åãè¡ããŸãã