
{"id":1051,"date":"2021-04-19T10:12:16","date_gmt":"2021-04-19T01:12:16","guid":{"rendered":"https:\/\/techmania.rensa.jp.net\/?p=1051"},"modified":"2023-08-02T11:56:23","modified_gmt":"2023-08-02T02:56:23","slug":"php0003","status":"publish","type":"post","link":"https:\/\/techmania.jp\/blog\/php0003\/","title":{"rendered":"PHP\uff5c\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u3092\u5177\u4f53\u4f8b\u3067\u73fe\u5f79\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u304c\u89e3\u8aac"},"content":{"rendered":"\n<h2 id=\"outline__1\" class=\"wp-block-heading\"><strong>PHP\u3068\u306f\uff1f<\/strong><\/h2>\n\n\n<p>PHP\uff08\u6b63\u5f0f\u540d\u79f0:Hypertext Preprocessor\uff09\u306f\u30011995\u5e74\u306b\u767b\u5834\u3057\u305f\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u3059\u3002Web\u30b5\u30fc\u30d3\u30b9\u3084Web\u30a2\u30d7\u30ea\u306e\u958b\u767a\u306b\u7279\u5316\u3057\u3066\u304a\u308a\u3001PHP\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u52d5\u7684\u306a\u30da\u30fc\u30b8\u3092\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n\n<h2 id=\"outline__2\" class=\"wp-block-heading\">\u5e38\u7528\u51e6\u7406<\/h2>\n\n\n\n<p>\u3053\u3053\u304b\u3089\u306fPHP\u3067\u4f7f\u3046\u3053\u3068\u304c\u591a\u3044\u51e6\u7406\u3092\u5177\u4f53\u7684\u306a\u66f8\u304d\u65b9\u3092\u4ea4\u3048\u3066\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 id=\"outline__2_1\" class=\"wp-block-heading\">\u57fa\u672c\u51e6\u7406<\/h3>\n\n\n\n<h4 id=\"outline__2_1_1\" class=\"wp-block-heading\">if\u69cb\u6587<\/h4>\n\n\n\n<p>\u300c\u3082\u3057\uff5e\u306a\u3089\u2026\u3059\u308b\u300d\u3068\u3044\u3063\u305f\u6761\u4ef6\u5206\u5c90\u3092\u8868\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:php decode:true \" title=\"if php\">$var = true;\n if( $var ) {\n     var_dump( $var );\n }<\/pre><\/div>\n\n\n\n<h4 id=\"outline__2_1_2\" class=\"wp-block-heading\">for\u69cb\u6587<\/h4>\n\n\n\n<p>PHP\u3067\u6700\u3082\u8907\u96d1\u306a\u30bf\u30a4\u30d7\u306e\u30eb\u30fc\u30d7\u3092\u8868\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:php decode:true \" title=\"for php\">for( $i = 0 ; $i &lt; 10 ; $i++ ) {\n     var_dump( $i );    \n}<\/pre><\/div>\n\n\n\n<h4 id=\"outline__2_1_3\" class=\"wp-block-heading\">while<meta charset=\"utf-8\">\u69cb\u6587<\/h4>\n\n\n\n<p>PHP\u3067\u6700\u3082\u7c21\u5358\u306a\u30bf\u30a4\u30d7\u306e\u30eb\u30fc\u30d7\u3092\u8868\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:php decode:true \" title=\"while php\">$count = 0;\n\/\/ \u6761\u4ef6\u304c true \u306e\u9593\u7e70\u308a\u8fd4\u3059\nwhile( $count &lt; 10 ) {\n    var_dump( $count );\n    $count++;\n}<\/pre><\/div>\n\n\n\n<h4 id=\"outline__2_1_4\" class=\"wp-block-heading\">switch<meta charset=\"utf-8\">\u69cb\u6587<\/h4>\n\n\n\n<p>if\u69cb\u6587\u3092\u4e26\u3079\u305f\u3082\u306e\u306b\u4f3c\u3066\u3044\u3066\u540c\u3058\u5909\u6570\u3092\u7570\u306a\u308b\u5024\u3068\u6bd4\u8f03\u3057\u3001\u5024\u306b\u5fdc\u3058\u3066\u7570\u306a\u3063\u305f\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u304d\u306b\u7528\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:php decode:true \" title=\"switch php\">$type = 1;\nswitch( $type ) {\n    case 0: var_dump( \"0\" ); break;\n    case 1: var_dump( \"1\" ); break;\n    case 2: var_dump( \"2\" ); break;\n    case 3: var_dump( \"3\" ); break;\n    default: var_dump( \"default\" ); break;\n}<\/pre><\/div>\n\n\n\n<h4 id=\"outline__2_1_5\" class=\"wp-block-heading\">class \u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u3068\u30e1\u30bd\u30c3\u30c9\u53c2\u7167<\/h4>\n\n\n\n<p>\u30d7\u30ed\u30d1\u30c6\u30a3\uff08\u5909\u6570\uff09\u3068\u30e1\u30bd\u30c3\u30c9\uff08\u95a2\u6570\uff09\u3092\u6301\u3063\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u8868\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:php decode:true \" title=\"class php\">class SampleClass {\n    function index( $text ) {\n        var_dump( $text );\n    }\n}\n\n$sampleClass = new SampleClass();\n$sampleClass-&gt;index(\"test text\");<\/pre><\/div>\n\n\n\n<h3 id=\"outline__2_2\" class=\"wp-block-heading\">\u6570\u5024\u51e6\u7406<\/h3>\n\n\n\n<h4 id=\"outline__2_2_1\" class=\"wp-block-heading\">abs \u7d76\u5bfe\u5024<\/h4>\n\n\n\n<p>\u8fd4\u308a\u5024\u3068\u3057\u3066\u7d76\u5bfe\u5024\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:php decode:true \" title=\"abs php\">$number = -50;\n$absValue = abs( $number );\nvar_dump( $absValue ); \/\/ 50<\/pre><\/div>\n\n\n\n<h3 id=\"outline__2_3\" class=\"wp-block-heading\">\u6587\u5b57\u5217\u51e6\u7406<\/h3>\n\n\n\n<h4 id=\"outline__2_3_1\" class=\"wp-block-heading\">explode \u6307\u5b9a\u6587\u5b57\u3067\u914d\u5217\u306b\u5206\u5272<\/h4>\n\n\n\n<p>\u6307\u5b9a\u3057\u305f\u533a\u5207\u308a\u6587\u5b57\u306b\u3088\u3063\u3066\u3001\u6587\u5b57\u5217\u3092\u5206\u5272\u3057\u3066\u914d\u5217\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:php decode:true \" title=\"explode php\">$value = \"a,b,c,d,e\";\n$explodeValue = explode( \",\" , $value );\nvar_dump( $explodeValue );<\/pre><\/div>\n\n\n\n<h4 id=\"outline__2_3_2\" class=\"wp-block-heading\">str_replace \u6587\u5b57\u5217\u306e\u7f6e\u63db<\/h4>\n\n\n\n<p>\u691c\u7d22\u3057\u305f\u6587\u5b57\u5217\u306b\u4e00\u81f4\u3057\u305f\u5168\u3066\u306e\u6587\u5b57\u5217\u3092\u7f6e\u63db\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:php decode:true \" title=\"str_replace php\">$value = \"aaabbbccc\";\n$value = str_replace( \"bbb\" , \"_bbb_\" , $value ); \/\/ \u691c\u7d22\u6587\u5b57 , \u7f6e\u63db\u5f8c\u6587\u5b57 , \u691c\u51fa\u5143\u6587\u5b57\u5217\nvar_dump( $value );<\/pre><\/div>\n\n\n\n<h4 id=\"outline__2_3_3\" class=\"wp-block-heading\">strpos \u6587\u5b57\u5217\u306e\u6709\u7121<\/h4>\n\n\n\n<p>\u6587\u5b57\u5217\u5185\u306e\u90e8\u5206\u6587\u5b57\u5217\u304c\u6700\u521d\u306b\u73fe\u308c\u308b\u5834\u6240\u3092\u898b\u3064\u3051\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:php decode:true \" title=\"strpos\">$value = \"sample\";\nif( strpos($value,'sam') !== false ){\n    var_dump( \"sam found\" );\n}<\/pre><\/div>\n\n\n\n<h4 id=\"outline__2_3_4\" class=\"wp-block-heading\">substr \u6587\u5b57\u5217\u306e\u4e00\u90e8\u62bd\u51fa<\/h4>\n\n\n\n<p>\u6307\u5b9a\u3057\u305f\u4f4d\u7f6e\u304b\u3089\u90e8\u5206\u6587\u5b57\u5217\u3092\u5207\u308a\u51fa\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:php decode:true \" title=\"substr php\">$str = substr(\"aiueo\", 0, -1);  \/\/ \"aiue\"<\/pre><\/div>\n\n\n\n<h3 id=\"outline__2_4\" class=\"wp-block-heading\">\u914d\u5217\u51e6\u7406<\/h3>\n\n\n\n<h4 id=\"outline__2_4_1\" class=\"wp-block-heading\">in_array \u914d\u5217\u5185\u306b\u5bfe\u8c61\u306e\u5024\u304c\u5b58\u5728\u3059\u308b\u304b<\/h4>\n\n\n\n<p>\u914d\u5217\u306e\u4e2d\u306b\u6307\u5b9a\u3057\u305f\u5024\u304c\u5b58\u5728\u3059\u308b\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b\u95a2\u6570\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:php decode:true \" title=\"in_array php\">$array = array('a', 'b', 'c');\n$isFound = in_array( \"a\" , $array ); \/\/ a \u304c\u914d\u5217\u306b\u5b58\u5728\u3059\u308b\u304b\u5224\u5b9a\nvar_dump( $isFound );<\/pre><\/div>\n\n\n\n<h4 id=\"outline__2_4_2\" class=\"wp-block-heading\">count \u8981\u7d20\u6570\u306e\u53d6\u5f97<\/h4>\n\n\n\n<p>\u914d\u5217\u306e\u8981\u7d20\u306e\u6570\u3092\u6570\u3048\u3001\u305d\u308c\u3092\u6570\u5024\u3068\u3057\u3066\u8fd4\u3059\u95a2\u6570\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:php decode:true \" title=\"count php\">$array = array('a', 'b', 'c');\n$length = count( $array );\nvar_dump( $length ); \/\/ 3<\/pre><\/div>\n\n\n\n<h4 id=\"outline__2_4_3\" class=\"wp-block-heading\">implode \u914d\u5217\u306e\u5024\u3067\u6307\u5b9a\u6587\u5b57\u3092\u631f\u3093\u3067\u7d50\u5408<\/h4>\n\n\n\n<p>\u914d\u5217\u3067\u6307\u5b9a\u3055\u308c\u305f\u8907\u6570\u306e\u6587\u5b57\u5217\u3092\u9023\u7d50\u3059\u308b\u305f\u3081\u306e\u95a2\u6570\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:php decode:true \" title=\"implode php\">$array = array('a', 'b', 'c');\n$str = implode(\"_\", $array);\nvar_dump( $str ); \/\/ a_b_c<\/pre><\/div>\n\n\n\n<h3 id=\"outline__2_5\" class=\"wp-block-heading\">try catch \u4f8b\u5916\u51e6\u7406<\/h3>\n\n\n\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u304f\u4eba\u304c\u60f3\u5b9a\u3057\u3066\u3044\u308b\u30a8\u30e9\u30fc\u306b\u5bfe\u3057\u3066\u306e\u51e6\u7406\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:php decode:true \" title=\"try catch php\">try {\n    \/\/ \u884c\u3044\u305f\u3044\u51e6\u7406\n} catch ( Exception $e ) {\n    echo $e;\n    \/\/ \u30a8\u30e9\u30fc\u6642\u306e\u51e6\u7406\n} finally {\n    \/\/ \u6700\u5f8c\u306b\u5fc5\u305a\u5b9f\u884c\u3055\u308c\u308b\u51e6\u7406\n}<\/pre><\/div>\n\n\n\n<h3 id=\"outline__2_6\" class=\"wp-block-heading\">\u7279\u6b8a\u306a\u51e6\u7406<\/h3>\n\n\n\n<h4 id=\"outline__2_6_1\" class=\"wp-block-heading\">gettype \u5909\u6570\u306e\u578b\u3092\u53d6\u5f97<\/h4>\n\n\n\n<p>\u6307\u5b9a\u3057\u305f\u5909\u6570\u306e\u578b\u3092\u78ba\u8a8d\u3059\u308b\u95a2\u6570\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:php decode:true \" title=\"gettype php\">$value = 100;\necho gettype( $value ); \/\/ integer<\/pre><\/div>\n\n\n\n<h4 id=\"outline__2_6_2\" class=\"wp-block-heading\">\u6587\u5b57\u5217\u304b\u3089\u5909\u6570\u3092\u53d6\u5f97<\/h4>\n\n\n\n<p>\u5909\u6570\u306e\u6587\u5b57\u5217\u3068\u3057\u3066\u306e\u5024\u3092\u53d6\u5f97\u3059\u308b\u51e6\u7406\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:php decode:true \" title=\"$\">$value = 100;\n${\"value\"} = 200;\necho $value ; \/\/ 200<\/pre><\/div>\n\n\n\n<h2 id=\"outline__3\" class=\"wp-block-heading\">\u6700\u5f8c\u306b<\/h2>\n\n\n\n<p>PHP\u306fCMS\u3001EC\u30b5\u30a4\u30c8\u3001SNS\u306a\u3069\u69d8\u3005\u306a\u5834\u9762\u3067\u5e83\u304f\u5229\u7528\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001\u7fd2\u5f97\u3059\u308c\u3070\u30a8\u30f3\u30b8\u30cb\u30a2\u3068\u3057\u3066\u306e\u30ad\u30e3\u30ea\u30a2\u306e\u5e45\u3092\u5e83\u3052\u3089\u308c\u307e\u3059\u3002<br>\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3057\u3084\u3059\u3044\u8a00\u8a9e\u3067\u3042\u308a\u3001\u5b66\u7fd2\u74b0\u5883\u3082\u5145\u5b9f\u3057\u3066\u3044\u308b\u306e\u3067\u305d\u308c\u3089\u3092\u6d3b\u7528\u3057\u3066\u7fd2\u5f97\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<blockquote class=\"wp-embedded-content\" data-secret=\"9P3bQI4Umo\"><a href=\"https:\/\/techmania.jp\/blog\/php0001\/\">PHP\u5165\u9580\uff5cPHP\u3068\u306f\uff1f\u7279\u5fb4\u3068\u66f8\u304d\u65b9<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;PHP\u5165\u9580\uff5cPHP\u3068\u306f\uff1f\u7279\u5fb4\u3068\u66f8\u304d\u65b9&#8221; &#8212; TechMania\" src=\"https:\/\/techmania.jp\/blog\/php0001\/embed\/#?secret=HNfgz0ZaOa#?secret=9P3bQI4Umo\" data-secret=\"9P3bQI4Umo\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n","protected":false},"excerpt":{"rendered":"PHP\u3068\u306f\uff1f PHP\uff08\u6b63\u5f0f\u540d\u79f0:Hypertext Preprocessor\uff09\u306f\u30011995\u5e74\u306b\u767b\u5834\u3057\u305f\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u3059\u3002Web\u30b5\u30fc\u30d3\u30b9\u3084Web\u30a2\u30d7\u30ea\u306e\u958b\u767a\u306b\u7279\u5316\u3057\u3066\u304a\u308a\u3001PHP\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u52d5\u7684\u306a\u30da\u30fc\u30b8\u3092\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002 \u5e38\u7528\u51e6\u7406 \u3053\u3053\u304b\u3089\u306fPHP\u3067\u4f7f\u3046\u3053\u3068\u304c\u591a\u3044\u51e6\u7406\u3092\u5177\u4f53\u7684\u306a\u66f8\u304d\u65b9\u3092\u4ea4\u3048\u3066\u7d39\u4ecb\u3057\u307e\u3059\u3002 \u57fa\u672c\u51e6\u7406 if\u69cb\u6587 \u300c\u3082\u3057\uff5e\u306a\u3089\u2026\u3059\u308b\u300d\u3068\u3044\u3063\u305f\u6761\u4ef6\u5206\u5c90\u3092\u8868\u3057\u307e\u3059\u3002 fo [&hellip;]","protected":false},"author":2,"featured_media":1053,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[28,51,60],"class_list":["post-1051","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming","tag-php","tag-jobs","tag-treatment"],"_links":{"self":[{"href":"https:\/\/techmania.jp\/blog\/wp-json\/wp\/v2\/posts\/1051","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techmania.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techmania.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techmania.jp\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/techmania.jp\/blog\/wp-json\/wp\/v2\/comments?post=1051"}],"version-history":[{"count":44,"href":"https:\/\/techmania.jp\/blog\/wp-json\/wp\/v2\/posts\/1051\/revisions"}],"predecessor-version":[{"id":5233,"href":"https:\/\/techmania.jp\/blog\/wp-json\/wp\/v2\/posts\/1051\/revisions\/5233"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techmania.jp\/blog\/wp-json\/wp\/v2\/media\/1053"}],"wp:attachment":[{"href":"https:\/\/techmania.jp\/blog\/wp-json\/wp\/v2\/media?parent=1051"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techmania.jp\/blog\/wp-json\/wp\/v2\/categories?post=1051"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techmania.jp\/blog\/wp-json\/wp\/v2\/tags?post=1051"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}