{"id":412,"date":"2023-03-27T23:02:53","date_gmt":"2023-03-27T14:02:53","guid":{"rendered":"https:\/\/baitimedx.com\/?p=412"},"modified":"2023-03-27T23:02:55","modified_gmt":"2023-03-27T14:02:55","slug":"php%e5%85%a5%e9%96%80-%e5%9f%ba%e6%9c%ac%e6%a7%8b%e6%96%87%e3%81%8b%e3%82%89%e3%82%aa%e3%83%96%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e6%8c%87%e5%90%91%e3%80%81%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab","status":"publish","type":"post","link":"https:\/\/baitimedx.com\/?p=412","title":{"rendered":"PHP\u5165\u9580 - \u57fa\u672c\u69cb\u6587\u304b\u3089\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u3001\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u307e\u3067\u308f\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"574\" src=\"https:\/\/baitimedx.com\/wp-content\/uploads\/2023\/03\/business-5475661_1280-1024x574.jpg\" alt=\"\" class=\"wp-image-413\" srcset=\"https:\/\/baitimedx.com\/wp-content\/uploads\/2023\/03\/business-5475661_1280-1024x574.jpg 1024w, https:\/\/baitimedx.com\/wp-content\/uploads\/2023\/03\/business-5475661_1280-300x168.jpg 300w, https:\/\/baitimedx.com\/wp-content\/uploads\/2023\/03\/business-5475661_1280-768x430.jpg 768w, https:\/\/baitimedx.com\/wp-content\/uploads\/2023\/03\/business-5475661_1280.jpg 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>PHP\u306f\u3001Web\u958b\u767a\u306e\u4e16\u754c\u3067\u5e83\u304f\u4f7f\u308f\u308c\u3066\u3044\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u8a00\u8a9e\u3067\u3059\u3002\u3053\u306e\u8a00\u8a9e\u3092\u5b66\u3076\u3053\u3068\u3067\u3001\u52b9\u7387\u7684\u306bWeb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001PHP\u306e\u57fa\u790e\u3092\u6bb5\u968e\u7684\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">PHP\u3068\u306f\uff1f<\/h2>\n\n\n\n<p>PHP\uff08Hypertext Preprocessor\uff09\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u3067\u52d5\u4f5c\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u8a00\u8a9e\u3067\u3001\u4e3b\u306bWeb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u958b\u767a\u306b\u7528\u3044\u3089\u308c\u307e\u3059\u30021994\u5e74\u306bRasmus Lerdorf\u306b\u3088\u3063\u3066\u958b\u767a\u3055\u308c\u3001\u4ee5\u964d\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u3068\u3057\u3066\u6210\u9577\u3057\u7d9a\u3051\u3066\u3044\u307e\u3059\u3002PHP\u306f\u3001HTML\u3068\u5bc6\u63a5\u306b\u9023\u643a\u3057\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3068\u306e\u9023\u643a\u3082\u5bb9\u6613\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">PHP\u306e\u74b0\u5883\u69cb\u7bc9<\/h2>\n\n\n\n<p>PHP\u306e\u958b\u767a\u74b0\u5883\u3092\u6574\u3048\u308b\u305f\u3081\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u624b\u9806\u3092\u8e0f\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<ol>\n<li><strong>\u30b5\u30fc\u30d0\u30fc\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong>\uff1aApache\u3084Nginx\u306a\u3069\u306eWeb\u30b5\u30fc\u30d0\u30fc\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>PHP\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong>\uff1a\u516c\u5f0f\u30b5\u30a4\u30c8\u304b\u3089\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u306ePHP\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong>\uff1aMySQL\u3084PostgreSQL\u306a\u3069\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>PHP\u3068\u30b5\u30fc\u30d0\u30fc\u306e\u9023\u643a<\/strong>\uff1aPHP\u3068Web\u30b5\u30fc\u30d0\u30fc\u304c\u9023\u643a\u3059\u308b\u3088\u3046\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u624b\u9806\u3092\u7d4c\u3066\u3001PHP\u306e\u958b\u767a\u74b0\u5883\u304c\u6574\u3044\u307e\u3057\u305f\u3002\u6b21\u306b\u3001PHP\u306e\u57fa\u672c\u69cb\u6587\u3092\u5b66\u3093\u3067\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">PHP\u306e\u57fa\u672c\u69cb\u6587<\/h2>\n\n\n\n<p>PHP\u306e\u30b3\u30fc\u30c9\u306f\u3001<code>&lt;?php<\/code>\u3068<code>?&gt;<\/code>\u30bf\u30b0\u3067\u56f2\u307e\u308c\u305f\u4e2d\u306b\u8a18\u8ff0\u3055\u308c\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u3001&#8221;Hello, World!&#8221;\u3092\u51fa\u529b\u3059\u308b\u30b7\u30f3\u30d7\u30eb\u306aPHP\u30b3\u30fc\u30c9\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\necho \"Hello, World!\";\n?><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5909\u6570\u3068\u30c7\u30fc\u30bf\u578b<\/h2>\n\n\n\n<p>PHP\u3067\u306f\u5909\u6570\u306e\u5ba3\u8a00\u306b<code>$<\/code>\u8a18\u53f7\u3092\u4f7f\u7528\u3057\u3001\u578b\u5ba3\u8a00\u306f\u4e0d\u8981\u3067\u3059\u3002\u4e3b\u306a\u30c7\u30fc\u30bf\u578b\u306b\u306f\u4ee5\u4e0b\u306e\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<ol>\n<li><span class=\"st-mymarker-s\">\u6574\u6570\u578b\uff08int\uff09<\/span><\/li>\n\n\n\n<li><span class=\"st-mymarker-s\">\u6d6e\u52d5\u5c0f\u6570\u70b9\u578b\uff08float\uff09<\/span><\/li>\n\n\n\n<li><span class=\"st-mymarker-s\">\u6587\u5b57\u5217\u578b\uff08string\uff09<\/span><\/li>\n\n\n\n<li><span class=\"st-mymarker-s\">\u914d\u5217\u578b\uff08array\uff09<\/span><\/li>\n\n\n\n<li><span class=\"st-mymarker-s\">\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u578b\uff08object\uff09<\/span><\/li>\n\n\n\n<li><span class=\"st-mymarker-s\">\u8ad6\u7406\u578b\uff08boolean\uff09<\/span><\/li>\n\n\n\n<li><span class=\"st-mymarker-s\">null\u578b\uff08NULL\uff09<\/span><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\n$integer = 42;\n$float = 3.14;\n$string = \"Hello, World!\";\n$array = array(1, 2, 3);\n$boolean = true;\n$null = NULL;\n?><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5236\u5fa1\u69cb\u9020<\/h2>\n\n\n\n<p>PHP\u3067\u306f\u3001if\u6587\u3001for\u6587\u3001foreach\u6587\u3001while\u6587\u306a\u3069\u306e\u5236\u5fa1\u69cb\u9020\u3092\u4f7f\u3063\u3066\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u6d41\u308c\u3092\u5236\u5fa1\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u3001\u5404\u5236\u5fa1\u69cb\u9020\u306e\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">if\u6587<\/h3>\n\n\n\n<p>\u6761\u4ef6\u5206\u5c90\u3092\u884c\u3046\u305f\u3081\u306e\u57fa\u672c\u7684\u306a\u69cb\u6587\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\n$age = 18;\n\nif ($age >= 20) {\n    echo \"You are an adult.\";\n} elseif ($age >= 13) {\n    echo \"You are a teenager.\";\n} else {\n    echo \"You are a child.\";\n}\n?><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">for\u6587<\/h3>\n\n\n\n<p>\u7e70\u308a\u8fd4\u3057\u51e6\u7406\u3092\u884c\u3046\u305f\u3081\u306e\u69cb\u6587\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\nfor ($i = 1; $i &lt;= 5; $i++) {\n    echo \"Iteration: $i\\n\";\n}\n?><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">foreach\u6587<\/h3>\n\n\n\n<p>\u914d\u5217\u306e\u8981\u7d20\u3092\u9806\u756a\u306b\u51e6\u7406\u3059\u308b\u305f\u3081\u306e\u69cb\u6587\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\n$fruits = array(\"apple\", \"banana\", \"cherry\");\n\nforeach ($fruits as $fruit) {\n    echo \"Fruit: $fruit\\n\";\n}\n?><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">while\u6587<\/h3>\n\n\n\n<p>\u6761\u4ef6\u304c\u771f\u3067\u3042\u308b\u9593\u3001\u7e70\u308a\u8fd4\u3057\u51e6\u7406\u3092\u884c\u3046\u69cb\u6587\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\n$count = 1;\n\nwhile ($count &lt;= 5) {\n    echo \"Count: $count\\n\";\n    $count++;\n}\n?><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u95a2\u6570\u3068\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411<\/h2>\n\n\n\n<p>PHP\u3067\u306f\u3001\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u30b3\u30fc\u30c9\u306e\u518d\u5229\u7528\u3084\u30e2\u30b8\u30e5\u30fc\u30eb\u5316\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u307e\u305f\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306b\u3082\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u3059\u3002\u4ee5\u4e0b\u3067\u306f\u3001\u95a2\u6570\u3068\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u95a2\u6570<\/h3>\n\n\n\n<p>\u95a2\u6570\u3092\u5b9a\u7fa9\u3059\u308b\u306b\u306f<code>function<\/code>\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u4f8b\u6587\u306f\u3001<code>$name<\/code>\u306b\u4ee3\u5165\u3055\u308c\u305f\u6587\u5b57\u3092<code>Hello<\/code>\u306e\u5f8c\u308d\u306b\u8fd4\u3059\u4f8b\u6587\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\nfunction greet($name) {\n    return \"Hello, $name!\";\n}\n\necho greet(\"John\");\n?><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u30af\u30e9\u30b9\u3068\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/h3>\n\n\n\n<p>\u30af\u30e9\u30b9\u3092\u5b9a\u7fa9\u3057\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3066\u64cd\u4f5c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u306f\u3001PHP\u3067\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u5b9f\u88c5\u3057\u305f\u4f8b\u3067\u3059\u3002<code>Person<\/code>\u30af\u30e9\u30b9\u3092\u5b9a\u7fa9\u3057\u3001\u305d\u306e\u4e2d\u306b<code>$name<\/code>\u30d7\u30ed\u30d1\u30c6\u30a3\u3068<code>greet()<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u6301\u305f\u305b\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p><code>greet()<\/code>\u30e1\u30bd\u30c3\u30c9\u306f\u3001<code>$name<\/code>\u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u683c\u7d0d\u3055\u308c\u305f\u540d\u524d\u3092\u4f7f\u3063\u3066\u3001\u6328\u62f6\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u305d\u306e\u5f8c\u3001<code>Person<\/code>\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\uff08\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\uff09\u3092\u4f5c\u6210\u3057\u3001<code>$person<\/code>\u5909\u6570\u306b\u683c\u7d0d\u3057\u307e\u3059\u3002<code>$person->name<\/code>\u306b&#8221;John&#8221;\u3068\u3044\u3046\u540d\u524d\u3092\u8a2d\u5b9a\u3057\u3001<code>$person->greet()<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u3066\u6328\u62f6\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\nclass Person {\n    public $name;\n    \n    public function greet() {\n        return \"Hello, {$this->name}!\";\n    }\n}\n\n$person = new Person();\n$person->name = \"John\";\necho $person->greet();\n?><\/code><\/pre>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u51fa\u529b\u304c\u5f97\u3089\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>Hello, John!<\/code><\/pre>\n\n\n\n<p>\u3053\u306e\u4f8b\u306f\u3001PHP\u3067\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u4f7f\u3063\u3066\u3001\u30b3\u30fc\u30c9\u306e\u518d\u5229\u7528\u3084\u30e2\u30b8\u30e5\u30fc\u30eb\u5316\u3092\u884c\u3046\u65b9\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u3068\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a<\/h2>\n\n\n\n<p>PHP\u3067\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u3084\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u306e\u63a5\u7d9a\u304c\u5bb9\u6613\u306b\u884c\u3048\u307e\u3059\u3002\u4ee5\u4e0b\u3067\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u3068\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u63a5\u7d9a\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c<\/h3>\n\n\n\n<p>\u3053\u306ePHP\u30b3\u30fc\u30c9\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u306b\u95a2\u3059\u308b\u4f8b\u3067\u3059\u3002<code>example.txt<\/code>\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u306b<code>Hello, World!<\/code>\u3068\u3044\u3046\u5185\u5bb9\u3092\u66f8\u304d\u8fbc\u3093\u3067\u3001\u305d\u306e\u5f8c\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u5185\u5bb9\u3092\u8aad\u307f\u8fbc\u3093\u3067\u51fa\u529b\u3059\u308b\u51e6\u7406\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<ol>\n<li><code>$file<\/code>\u5909\u6570\u306b\u30d5\u30a1\u30a4\u30eb\u540d<code>example.txt<\/code>\u3092\u683c\u7d0d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>$content<\/code>\u5909\u6570\u306b\u66f8\u304d\u8fbc\u3080\u5185\u5bb9<code>Hello, World!<\/code>\u3092\u683c\u7d0d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>file_put_contents()<\/code>\u95a2\u6570\u3092\u4f7f\u3063\u3066\u3001<code>$file<\/code>\u3067\u6307\u5b9a\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u306b<code>$content<\/code>\u306e\u5185\u5bb9\u3092\u66f8\u304d\u8fbc\u307f\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>file_get_contents()<\/code>\u95a2\u6570\u3092\u4f7f\u3063\u3066\u3001<code>$file<\/code>\u3067\u6307\u5b9a\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u5185\u5bb9\u3092\u8aad\u307f\u8fbc\u307f\u3001<code>echo<\/code>\u3067\u51fa\u529b\u3057\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\n$file = \"example.txt\";\n$content = \"Hello, World!\";\n\n\/\/ \u30d5\u30a1\u30a4\u30eb\u3078\u66f8\u304d\u8fbc\u307f\nfile_put_contents($file, $content);\n\n\/\/ \u30d5\u30a1\u30a4\u30eb\u304b\u3089\u8aad\u307f\u8fbc\u307f\necho file_get_contents($file);\n?><\/code><\/pre>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u51fa\u529b\u304c\u5f97\u3089\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>Hello, World!<\/code><\/pre>\n\n\n\n<p>\u3053\u306e\u4f8b\u306f\u3001PHP\u3067\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u66f8\u304d\u3092\u884c\u3046\u57fa\u672c\u7684\u306a\u65b9\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">MySQL\u3078\u306e\u63a5\u7d9a<\/h3>\n\n\n\n<p>\u3053\u306ePHP\u30b3\u30fc\u30c9\u306f\u3001MySQL\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3059\u308b\u4f8b\u3067\u3059\u3002PDO\uff08PHP Data Objects\uff09\u3092\u4f7f\u7528\u3057\u3066\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3057\u3001\u6210\u529f\u3057\u305f\u5834\u5408\u306f &#8220;Connected successfully&#8221; \u3068\u3044\u3046\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u529b\u3057\u3001\u5931\u6557\u3057\u305f\u5834\u5408\u306f\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol>\n<li><code>$host<\/code>\u5909\u6570\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30db\u30b9\u30c8\uff08\u901a\u5e38\u306f<code>localhost<\/code>\uff09\u3092\u683c\u7d0d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>$dbname<\/code>\u5909\u6570\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d\u3092\u683c\u7d0d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>$username<\/code>\u5909\u6570\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u306e\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u683c\u7d0d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>$password<\/code>\u5909\u6570\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u683c\u7d0d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>try<\/code>\u30d6\u30ed\u30c3\u30af\u306e\u4e2d\u3067\u3001<code>new PDO()<\/code>\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u3092\u8a66\u307f\u307e\u3059\u3002\u63a5\u7d9a\u6587\u5b57\u5217\u3001\u30e6\u30fc\u30b6\u30fc\u540d\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5f15\u6570\u306b\u6e21\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>$pdo-&gt;setAttribute()<\/code>\u3092\u4f7f\u3063\u3066\u3001\u30a8\u30e9\u30fc\u30e2\u30fc\u30c9\u3092<code>PDO::ERRMODE_EXCEPTION<\/code>\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u64cd\u4f5c\u4e2d\u306b\u554f\u984c\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u3001PDOException\u304c\u30b9\u30ed\u30fc\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u63a5\u7d9a\u304c\u6210\u529f\u3057\u305f\u5834\u5408\u306f\u3001&#8221;Connected successfully&#8221;\u3068\u3044\u3046\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u529b\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>catch<\/code>\u30d6\u30ed\u30c3\u30af\u3067PDOException\u3092\u6355\u6349\u3057\u3001\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u529b\u3057\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\n$host = \"localhost\";\n$dbname = \"my_database\";\n$username = \"user\";\n$password = \"password\";\n\ntry {\n    $pdo = new PDO(\"mysql:host=$host;dbname=$dbname\", $username, $password);\n    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);\n    echo \"Connected successfully\";\n} catch (PDOException $e) {\n    echo \"Connection failed: \" . $e->getMessage();\n}\n?><\/code><\/pre>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u304c\u6210\u529f\u3057\u305f\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u51fa\u529b\u304c\u5f97\u3089\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Copy code<code>Connected successfully\n<\/code><\/pre>\n\n\n\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u306b\u5931\u6557\u3057\u305f\u5834\u5408\u306f\u3001\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u4f8b\u306f\u3001PHP\u3067MySQL\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3059\u308b\u57fa\u672c\u7684\u306a\u65b9\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30c7\u30fc\u30bf\u306e\u53d6\u5f97\u3068\u64cd\u4f5c<\/h3>\n\n\n\n<p>\u3053\u306ePHP\u30b3\u30fc\u30c9\u306f\u3001PDO\uff08PHP Data Objects\uff09\u3092\u4f7f\u7528\u3057\u3066MySQL\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\uff08SELECT\uff09\u3057\u3001\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\uff08INSERT\uff09\u3059\u308b\u4f8b\u3067\u3059\u3002\u540c\u69d8\u306e\u65b9\u6cd5\u3067\u3001\u66f4\u65b0\uff08UPDATE\uff09\u3084\u524a\u9664\uff08DELETE\uff09\u3082\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<ol>\n<li><code>SELECT<\/code>\u6587\u3092\u4f7f\u3063\u3066\u3001<code>users<\/code>\u30c6\u30fc\u30d6\u30eb\u304b\u3089<code>id<\/code>\u3068<code>name<\/code>\u30ab\u30e9\u30e0\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308bSQL\u30af\u30a8\u30ea\u3092<code>$sql<\/code>\u5909\u6570\u306b\u683c\u7d0d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>$pdo-&gt;query()<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u3001SQL\u30af\u30a8\u30ea\u3092\u5b9f\u884c\u3057\u3001\u7d50\u679c\u3092<code>$stmt<\/code>\u5909\u6570\u306b\u683c\u7d0d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>while<\/code>\u30eb\u30fc\u30d7\u3068<code>$stmt-&gt;fetch()<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u3001\u7d50\u679c\u30bb\u30c3\u30c8\u304b\u30891\u884c\u305a\u3064\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3001\u9023\u60f3\u914d\u5217\u5f62\u5f0f\uff08<code>PDO::FETCH_ASSOC<\/code>\uff09\u3067<code>$row<\/code>\u5909\u6570\u306b\u683c\u7d0d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>echo<\/code>\u3092\u4f7f\u3063\u3066\u3001<code>$row<\/code>\u304b\u3089<code>id<\/code>\u3068<code>name<\/code>\u30ab\u30e9\u30e0\u306e\u30c7\u30fc\u30bf\u3092\u51fa\u529b\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>INSERT<\/code>\u6587\u3092\u4f7f\u3063\u3066\u3001<code>users<\/code>\u30c6\u30fc\u30d6\u30eb\u306b\u65b0\u3057\u3044\u30e6\u30fc\u30b6\u30fc\u3092\u8ffd\u52a0\u3059\u308bSQL\u30af\u30a8\u30ea\u3092<code>$new_user<\/code>\u5909\u6570\u306b\u683c\u7d0d\u3057\u307e\u3059\u3002\u30d7\u30ec\u30fc\u30b9\u30db\u30eb\u30c0\uff08<code>?<\/code>\uff09\u3092\u4f7f\u3063\u3066\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>$pdo-&gt;prepare()<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u3001SQL\u30af\u30a8\u30ea\u3092\u6e96\u5099\u3057\u3001<code>$stmt<\/code>\u5909\u6570\u306b\u683c\u7d0d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>$stmt-&gt;execute()<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u3001SQL\u30af\u30a8\u30ea\u3092\u5b9f\u884c\u3057\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u5024\uff08<code>\"John Doe\"<\/code>\u3068<code>\"john@example.com\"<\/code>\uff09\u3092\u914d\u5217\u3068\u3057\u3066\u6e21\u3057\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30c7\u30fc\u30bf\u304c\u53d6\u5f97\u3055\u308c\u3001\u65b0\u3057\u3044\u30e6\u30fc\u30b6\u30fc\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002\u51fa\u529b\u7d50\u679c\u306f\u3001\u53d6\u5f97\u3055\u308c\u305f\u30e6\u30fc\u30b6\u30fc\u306eID\u3068\u540d\u524d\u3092\u8868\u793a\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6ce8\u610f: \u3053\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u524d\u306b\u3001\u524d\u8ff0\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3057\u3066<code>$pdo<\/code>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;?php\n\/\/ SELECT\u6587\u306e\u5b9f\u884c\n$sql = \"SELECT id, name FROM users\";\n$stmt = $pdo->query($sql);\n\n\/\/ \u7d50\u679c\u306e\u53d6\u5f97\nwhile ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {\n    echo \"ID: \" . $row['id'] . \" Name: \" . $row['name'] . \"\\n\";\n}\n\n\/\/ INSERT\u6587\u306e\u5b9f\u884c\n$new_user = \"INSERT INTO users (name, email) VALUES (?, ?)\";\n$stmt = $pdo->prepare($new_user);\n$stmt->execute([\"John Doe\", \"john@example.com\"]);\n\n\/\/ \u66f4\u65b0\u3001\u524a\u9664\u3082\u540c\u69d8\u306b\u884c\u3048\u307e\u3059\n?><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u3053\u306e\u30d6\u30ed\u30b0\u8a18\u4e8b\u3067\u306f\u3001PHP\u306e\u57fa\u790e\u306b\u3064\u3044\u3066\u5b66\u3073\u307e\u3057\u305f\u3002PHP\u306fWeb\u958b\u767a\u306b\u304a\u3044\u3066\u975e\u5e38\u306b\u5f37\u529b\u3067\u67d4\u8edf\u6027\u306e\u9ad8\u3044\u8a00\u8a9e\u3067\u3042\u308a\u3001\u69d8\u3005\u306a\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u5229\u7528\u3067\u304d\u307e\u3059\u3002\u5f15\u304d\u7d9a\u304d\u3001PHP\u306e\u5b66\u7fd2\u3092\u9032\u3081\u3066\u3001\u3055\u3089\u306b\u9ad8\u5ea6\u306a\u6a5f\u80fd\u3084\u6280\u8853\u3092\u7fd2\u5f97\u3057\u3001\u30b9\u30ad\u30eb\u3092\u78e8\u3044\u3066\u3044\u304f\u3053\u3068\u3067\u3001\u526f\u696d\u3084\u8ee2\u8077\u3092\u6709\u5229\u306b\u9032\u3081\u3066\u3044\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u89e3\u8aac\u3057\u305f\u57fa\u672c\u7684\u306a\u77e5\u8b58\u3092\u304d\u3063\u304b\u3051\u306b\u3001\u5b66\u7fd2\u306b\u53d6\u308a\u7d44\u307f\u3084\u3059\u304f\u306a\u308b\u3068\u5b09\u3057\u3044\u3067\u3059\uff01<\/p>\n\n\n\n<p>\u4eca\u5f8c\u3082\u3001IT\u3084DX\u3001\u6295\u8cc7\u7b49\u306b\u95a2\u3059\u308b\u4eba\u751f\u3092\u8c4a\u304b\u306b\u3057\u3066\u81ea\u7531\u306a\u6642\u9593\u3092\u5897\u3084\u305b\u308b\u3088\u3046\u306a\u60c5\u5831\u3092\u767a\u4fe1\u3057\u3066\u3044\u304d\u307e\u3059\u306e\u3067\u662f\u975e\u304a\u697d\u3057\u307f\u306b\uff01<\/p>\n\n\n\n<p><strong>\u2193\u3000\u30aa\u30b9\u30b9\u30e1\u8a18\u4e8b\u3000\u2193<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/baitimedx.com\/?p=409\">\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u57fa\u790e\uff1fMySQL\u5165\u9580 &#8211; \u57fa\u672c\u6982\u5ff5\u304b\u3089\u57fa\u672c\u7684\u306a\u64cd\u4f5c\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/baitimedx.com\/?p=404\">\u901a\u4fe1\u30d7\u30ed\u30c8\u30b3\u30eb\u306e\u57fa\u790e\u3068\u305d\u306e\u91cd\u8981\u6027 &#8211; \u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u306b\u304a\u3051\u308b\u8981\u306e\u6280\u8853\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/baitimedx.com\/?p=400\">\u958b\u767a\u3092\u52a0\u901f\u3055\u305b\u308b\u9769\u65b0\u7684\u30c4\u30fc\u30ebDocker\u306e\u57fa\u790e &#8211; \u521d\u5fc3\u8005\u5411\u3051\u306b\u308f\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3057\u307e\u3059\uff01<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP\u306f\u3001Web\u958b\u767a\u306e\u4e16\u754c\u3067\u5e83\u304f\u4f7f\u308f\u308c\u3066\u3044\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u8a00\u8a9e\u3067\u3059\u3002\u3053\u306e\u8a00\u8a9e\u3092\u5b66\u3076\u3053\u3068\u3067\u3001\u52b9\u7387\u7684\u306bWeb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001PHP\u306e\u57fa\u790e\u3092\u6bb5\u968e\u7684\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002 PHP\u3068 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":413,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","jetpack_publicize_message":"PHP\u5165\u9580 - \u57fa\u672c\u69cb\u6587\u304b\u3089\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u3001\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u307e\u3067\u308f\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[10],"tags":[17,16],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/baitimedx.com\/wp-content\/uploads\/2023\/03\/business-5475661_1280.jpg","_links":{"self":[{"href":"https:\/\/baitimedx.com\/index.php?rest_route=\/wp\/v2\/posts\/412"}],"collection":[{"href":"https:\/\/baitimedx.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/baitimedx.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/baitimedx.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/baitimedx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=412"}],"version-history":[{"count":1,"href":"https:\/\/baitimedx.com\/index.php?rest_route=\/wp\/v2\/posts\/412\/revisions"}],"predecessor-version":[{"id":414,"href":"https:\/\/baitimedx.com\/index.php?rest_route=\/wp\/v2\/posts\/412\/revisions\/414"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/baitimedx.com\/index.php?rest_route=\/wp\/v2\/media\/413"}],"wp:attachment":[{"href":"https:\/\/baitimedx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/baitimedx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/baitimedx.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}