{"id":788,"date":"2025-08-04T16:17:54","date_gmt":"2025-08-04T07:17:54","guid":{"rendered":"https:\/\/nexive.tech\/?p=788"},"modified":"2025-08-04T16:17:55","modified_gmt":"2025-08-04T07:17:55","slug":"%e3%80%90%e3%82%b5%e3%82%af%e3%83%83%e3%81%a8%e8%a7%a3%e8%aa%ac%e3%80%91php%e3%81%a7%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%82%92%e8%aa%ad%e3%81%bf%e6%9b%b8%e3%81%8d%e3%81%99%e3%82%8b%e5%9f%ba","status":"publish","type":"post","link":"https:\/\/nexive.tech\/?p=788","title":{"rendered":"\u3010\u30b5\u30af\u30c3\u3068\u89e3\u8aac\u3011PHP\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u66f8\u304d\u3059\u308b\u57fa\u672c\uff08fopen\/fwrite\/fclose\uff09"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">1. \u672c\u8a18\u4e8b\u306e\u30dd\u30a4\u30f3\u30c8<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>PHP\u3067\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u66f8\u304d\u3092\u884c\u3046\u57fa\u672c\u69cb\u6587\uff08fopen\/fwrite\/fclose\uff09\u3092\u89e3\u8aac<\/li>\n\n\n\n<li>\u66f8\u304d\u8fbc\u307f\u30fb\u8aad\u307f\u8fbc\u307f\u30fb\u8ffd\u8a18\u306a\u3069\u306e\u64cd\u4f5c\u30e2\u30fc\u30c9\u3068\u305d\u306e\u4f7f\u3044\u5206\u3051\u3092\u7d39\u4ecb<\/li>\n\n\n\n<li>\u5b9f\u52d9\u3067\u6ce8\u610f\u3059\u3079\u304d\u30a8\u30e9\u30fc\u51e6\u7406\u3084\u30ed\u30c3\u30af\u5236\u5fa1\u306e\u8003\u616e\u70b9\u3082\u542b\u3081\u3066\u8aac\u660e<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">2. PHP\u306e\u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u66f8\u304d\u3068\u306f\uff1f<\/h2>\n\n\n\n<p>PHP\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u3067\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u3092\u884c\u3046\u305f\u3081\u306e\u6a19\u6e96\u95a2\u6570\u7fa4\u3092\u63d0\u4f9b\u3057\u3066\u304a\u308a\u3001\u30ed\u30b0\u51fa\u529b\u3084\u4e00\u6642\u30c7\u30fc\u30bf\u306e\u4fdd\u5b58\u306a\u3069\u306b\u6d3b\u7528\u3055\u308c\u307e\u3059\u3002\u7279\u306b<code>fopen()<\/code>\u3001<code>fwrite()<\/code>\u3001<code>fclose()<\/code>\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u66f8\u304d\u3092\u884c\u3046\u4e0a\u3067\u306e\u57fa\u672c\u95a2\u6570\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u95a2\u6570\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u3001\u66f8\u304d\u8fbc\u307f\u3001\u8ffd\u8a18\u3068\u3044\u3063\u305f\u51e6\u7406\u3092\u67d4\u8edf\u306b\u5236\u5fa1\u3067\u304d\u307e\u3059\u3002\u8aad\u307f\u66f8\u304d\u306b\u306f\u30e2\u30fc\u30c9\u306e\u6307\u5b9a\u304c\u5fc5\u8981\u3067\u3001\u30d5\u30a1\u30a4\u30eb\u3092\u65b0\u898f\u4f5c\u6210\u3059\u308b\u306e\u304b\u3001\u65e2\u5b58\u306e\u5185\u5bb9\u3092\u8ffd\u8a18\u3059\u308b\u306e\u304b\u3068\u3044\u3063\u305f\u76ee\u7684\u306b\u3088\u3063\u3066\u4f7f\u3044\u5206\u3051\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u5b9f\u52d9\u3067\u306f\u3001\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u3078\u306e\u8ffd\u8a18\u3084\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u53d6\u308a\u3001\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\u306a\u3069\u306b\u5229\u7528\u3055\u308c\u308b\u5834\u9762\u304c\u591a\u304f\u3042\u308a\u307e\u3059\u3002\u8aad\u307f\u66f8\u304d\u306b\u306f\u30d5\u30a1\u30a4\u30eb\u306e\u5b58\u5728\u30c1\u30a7\u30c3\u30af\u3084\u66f8\u304d\u8fbc\u307f\u6a29\u9650\u306e\u78ba\u8a8d\u304c\u5fc5\u8981\u306a\u5834\u5408\u3082\u3042\u308a\u3001\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u3082\u6b20\u304b\u305b\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. \u8a73\u7d30\u89e3\u8aac<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u57fa\u672c\u7684\u306a\u66f8\u304d\u8fbc\u307f\uff08\u65b0\u898f\u4f5c\u6210\uff09<\/h3>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u306b\u65b0\u3057\u304f\u30c7\u30fc\u30bf\u3092\u66f8\u304d\u8fbc\u3080\u306b\u306f\u3001<code>fopen()<\/code>\u3067\u30e2\u30fc\u30c9<code>\"w\"<\/code>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;?php\n\/\/ \u30d5\u30a1\u30a4\u30eb\u3092\u65b0\u898f\u4f5c\u6210\u3057\u3066\u66f8\u304d\u8fbc\u3080\n$file = fopen('sample.txt', 'w');\nif ($file) {\n    fwrite($file, \"\u3053\u3093\u306b\u3061\u306f\u3001PHP\u30d5\u30a1\u30a4\u30eb\u66f8\u304d\u8fbc\u307f\\n\");\n    fclose($file);\n}\n?>\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A9955\">\/\/ \u30d5\u30a1\u30a4\u30eb\u3092\u65b0\u898f\u4f5c\u6210\u3057\u3066\u66f8\u304d\u8fbc\u3080<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #DCDCAA\">fopen<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&#39;sample.txt&#39;<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #CE9178\">&#39;w&#39;<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">fwrite<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #CE9178\">&quot;\u3053\u3093\u306b\u3061\u306f\u3001PHP\u30d5\u30a1\u30a4\u30eb\u66f8\u304d\u8fbc\u307f<\/span><span style=\"color: #D7BA7D\">\\n<\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">fclose<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">?&gt;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u306e\u4f8b\u3067\u306f\u3001<code>sample.txt<\/code>\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306f\u65b0\u898f\u4f5c\u6210\u3055\u308c\u3001\u5b58\u5728\u3059\u308b\u5834\u5408\u306f\u4e2d\u8eab\u304c\u4e0a\u66f8\u304d\u3055\u308c\u307e\u3059\u3002\u66f8\u304d\u8fbc\u307f\u5f8c\u306f<code>fclose()<\/code>\u3067\u5fc5\u305a\u30d5\u30a1\u30a4\u30eb\u3092\u9589\u3058\u3066\u30ea\u30bd\u30fc\u30b9\u3092\u89e3\u653e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d5\u30a1\u30a4\u30eb\u3078\u306e\u8ffd\u8a18<\/h3>\n\n\n\n<p>\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u306a\u3069\u3067\u65e2\u5b58\u5185\u5bb9\u3092\u4fdd\u6301\u3057\u305f\u307e\u307e\u8ffd\u52a0\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u30e2\u30fc\u30c9\u306b<code>\"a\"<\/code>\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;?php\n\/\/ \u65e2\u5b58\u30d5\u30a1\u30a4\u30eb\u306b\u8ffd\u8a18\u3059\u308b\n$file = fopen('sample.txt', 'a');\nif ($file) {\n    fwrite($file, \"\u3053\u306e\u884c\u306f\u8ffd\u8a18\u3067\u3059\\n\");\n    fclose($file);\n}\n?>\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A9955\">\/\/ \u65e2\u5b58\u30d5\u30a1\u30a4\u30eb\u306b\u8ffd\u8a18\u3059\u308b<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #DCDCAA\">fopen<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&#39;sample.txt&#39;<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #CE9178\">&#39;a&#39;<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">fwrite<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #CE9178\">&quot;\u3053\u306e\u884c\u306f\u8ffd\u8a18\u3067\u3059<\/span><span style=\"color: #D7BA7D\">\\n<\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">fclose<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">?&gt;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u8ffd\u8a18\u30e2\u30fc\u30c9\u3067\u306f\u30d5\u30a1\u30a4\u30eb\u306e\u672b\u5c3e\u306b\u5185\u5bb9\u304c\u8ffd\u52a0\u3055\u308c\u3001\u5143\u306e\u5185\u5bb9\u306f\u4fdd\u6301\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f<\/h3>\n\n\n\n<p>\u8aad\u307f\u8fbc\u307f\u306b\u306f\u30e2\u30fc\u30c9\u306b<code>\"r\"<\/code>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u8aad\u307f\u8fbc\u3093\u3060\u5185\u5bb9\u3092\u5909\u6570\u306b\u683c\u7d0d\u3057\u3066\u51e6\u7406\u3059\u308b\u3053\u3068\u304c\u4e00\u822c\u7684\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;?php\n\/\/ \u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\n$file = fopen('sample.txt', 'r');\nif ($file) {\n    $content = fread($file, filesize('sample.txt'));\n    fclose($file);\n    echo $content;\n}\n?>\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A9955\">\/\/ \u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #DCDCAA\">fopen<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&#39;sample.txt&#39;<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #CE9178\">&#39;r&#39;<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #9CDCFE\">$content<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #DCDCAA\">fread<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #DCDCAA\">filesize<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&#39;sample.txt&#39;<\/span><span style=\"color: #D4D4D4\">));<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">fclose<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">$content<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">?&gt;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u306e\u4f8b\u3067\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u5168\u5185\u5bb9\u3092\u8aad\u307f\u8fbc\u3093\u3067\u8868\u793a\u3057\u3066\u3044\u307e\u3059\u3002\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u306e\u53d6\u5f97\u306b\u306f<code>filesize()<\/code>\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">fopen\u306e\u30e2\u30fc\u30c9\u3068\u610f\u5473\u306e\u6bd4\u8f03<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30e2\u30fc\u30c9<\/th><th>\u8aac\u660e<\/th><\/tr><\/thead><tbody><tr><td>r<\/td><td>\u8aad\u307f\u8fbc\u307f\u5c02\u7528<\/td><\/tr><tr><td>w<\/td><td>\u66f8\u304d\u8fbc\u307f\u5c02\u7528\uff08\u5185\u5bb9\u4e0a\u66f8\u304d\uff09<\/td><\/tr><tr><td>a<\/td><td>\u66f8\u304d\u8fbc\u307f\u5c02\u7528\uff08\u672b\u5c3e\u8ffd\u8a18\uff09<\/td><\/tr><tr><td>r+<\/td><td>\u8aad\u307f\u66f8\u304d\uff08\u4e0a\u66f8\u304d\uff09<\/td><\/tr><tr><td>a+<\/td><td>\u8aad\u307f\u66f8\u304d\uff08\u8ffd\u8a18\uff09<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">4. \u3088\u304f\u3042\u308b\u30df\u30b9\u30fb\u8aa4\u89e3\u30fb\u843d\u3068\u3057\u7a74<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d5\u30a1\u30a4\u30eb\u304c\u958b\u3051\u306a\u3044\u5834\u5408\u306e\u5bfe\u51e6\u3092\u3057\u3066\u3044\u306a\u3044<\/h3>\n\n\n\n<p><code>fopen()<\/code>\u306e\u623b\u308a\u5024\u304c<code>false<\/code>\u306e\u307e\u307e<code>fwrite()<\/code>\u3092\u5b9f\u884c\u3059\u308b\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002\u5fc5\u305a\u623b\u308a\u5024\u306e\u30c1\u30a7\u30c3\u30af\u3092\u5165\u308c\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d5\u30a1\u30a4\u30eb\u30ed\u30c3\u30af\u3092\u8003\u616e\u3057\u3066\u3044\u306a\u3044<\/h3>\n\n\n\n<p>\u540c\u6642\u30a2\u30af\u30bb\u30b9\u304c\u767a\u751f\u3057\u3046\u308b\u74b0\u5883\u3067\u306f\u3001<code>flock()<\/code>\u306b\u3088\u308b\u6392\u4ed6\u5236\u5fa1\u3092\u691c\u8a0e\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;?php\n$file = fopen('sample.txt', 'a');\nif ($file &amp;&amp; flock($file, LOCK_EX)) {\n    fwrite($file, \"\u540c\u6642\u30a2\u30af\u30bb\u30b9\u5bfe\u7b56\\n\");\n    flock($file, LOCK_UN);\n    fclose($file);\n}\n?>\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #DCDCAA\">fopen<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&#39;sample.txt&#39;<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #CE9178\">&#39;a&#39;<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\"> &amp;&amp; <\/span><span style=\"color: #DCDCAA\">flock<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\">, LOCK_EX)) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">fwrite<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #CE9178\">&quot;\u540c\u6642\u30a2\u30af\u30bb\u30b9\u5bfe\u7b56<\/span><span style=\"color: #D7BA7D\">\\n<\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">flock<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\">, LOCK_UN);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">fclose<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">?&gt;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u76f8\u5bfe\u30d1\u30b9\u3068\u6a29\u9650\u306e\u8aa4\u89e3<\/h3>\n\n\n\n<p>Web\u30b5\u30fc\u30d0\u30fc\u306e\u5b9f\u884c\u30e6\u30fc\u30b6\u30fc\u306b\u30d5\u30a1\u30a4\u30eb\u66f8\u304d\u8fbc\u307f\u6a29\u9650\u304c\u306a\u3051\u308c\u3070\u3001<code>fopen()<\/code>\u306f\u5931\u6557\u3057\u307e\u3059\u3002\u7279\u306b\u76f8\u5bfe\u30d1\u30b9\u3092\u4f7f\u3046\u5834\u5408\u3001\u5b9f\u884c\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3068\u66f8\u304d\u8fbc\u307f\u5148\u306e\u6574\u5408\u6027\u306b\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. \u307e\u3068\u3081<\/h2>\n\n\n\n<p>PHP\u306e\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u306f\u3001<code>fopen()<\/code>\u3001<code>fwrite()<\/code>\u3001<code>fclose()<\/code>\u306e\u7d44\u307f\u5408\u308f\u305b\u3067\u67d4\u8edf\u306b\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002\u8aad\u307f\u66f8\u304d\u30e2\u30fc\u30c9\u3092\u9069\u5207\u306b\u9078\u3073\u3001\u623b\u308a\u5024\u3084\u6a29\u9650\u306e\u78ba\u8a8d\u3001\u540c\u6642\u30a2\u30af\u30bb\u30b9\u3078\u306e\u914d\u616e\u3092\u884c\u3046\u3053\u3068\u3067\u3001\u5b89\u5168\u304b\u3064\u78ba\u5b9f\u306a\u30d5\u30a1\u30a4\u30eb\u51e6\u7406\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u672c\u8a18\u4e8b\u306e\u30dd\u30a4\u30f3\u30c8 2. PHP\u306e\u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u66f8\u304d\u3068\u306f\uff1f PHP\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u3067\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u3092\u884c\u3046\u305f\u3081\u306e\u6a19\u6e96\u95a2\u6570\u7fa4\u3092\u63d0\u4f9b\u3057\u3066\u304a\u308a\u3001\u30ed\u30b0\u51fa\u529b\u3084\u4e00\u6642\u30c7\u30fc\u30bf\u306e\u4fdd\u5b58\u306a\u3069\u306b\u6d3b\u7528\u3055\u308c\u307e\u3059\u3002\u7279\u306bfopen()\u3001fwrite() [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":706,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[85],"tags":[],"class_list":["post-788","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/788","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=788"}],"version-history":[{"count":2,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/788\/revisions"}],"predecessor-version":[{"id":877,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/788\/revisions\/877"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/media\/706"}],"wp:attachment":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}