{"id":10390,"date":"2020-05-04T11:54:54","date_gmt":"2020-05-04T02:54:54","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=10390"},"modified":"2023-05-27T21:19:14","modified_gmt":"2023-05-27T12:19:14","slug":"%e3%80%90php%e3%80%91%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e8%aa%ad%e3%81%bf%e8%be%bc%e3%81%bf","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=10390","title":{"rendered":"\u3010PHP\u3011\u5916\u90e8\u306ePHP\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u3046\u306b\u306f"},"content":{"rendered":"<p>PHP\u3067\u306e\u5916\u90e8\u306ePHP\u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u8fbc\u307f\u306f\u4e0b\u8a18\u306e\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>require<\/li>\n<li>include<\/li>\n<li>\u540d\u524d\u7a7a\u9593<\/li>\n<\/ul>\n<p>\u3069\u308c\u3067\u3082\u826f\u3044\u3067\u3059\u304c\u4e00\u822c\u7684\u306aPHP\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u306f<span style=\"color: #ff0000;\"><strong>require\u304c\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u969b\u306b\u3061\u3083\u3093\u3068\u51e6\u7406\u304c\u6b62\u307e\u308b\u306e\u3067\u4e3b\u6d41<\/strong><\/span>\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<span style=\"color: #ff0000;\"><strong>Laravel\u3067\u306f\u540d\u524d\u7a7a\u9593\u306b\u3088\u308a\u30d5\u30a1\u30a4\u30eb\u51e6\u7406\u3092\u3059\u308b\u4e8b\u304c\u4e3b\u6d41<\/strong><\/span>\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>require()<\/h2>\n<p>\u3082\u3057\u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u8fbc\u307f\u6642\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u3089\u8aad\u307f\u8fbc\u307f\u51e6\u7406\u304c\u505c\u6b62\u3057\u307e\u3059\u3002<\/p>\n<h3>\u8aad\u307f\u8fbc\u307e\u308c\u308b\u30d5\u30a1\u30a4\u30eb(common.php)<\/h3>\n<pre class=\"lang:default decode:true \">&lt;?php\r\n\r\n$val = \"\u5909\u6570\";\r\n\r\nfunction kansu(){\r\n  echo \"\u95a2\u6570\";\r\n}\r\n\r\n?&gt;<\/pre>\n<h3>\u8aad\u307f\u8fbc\u3080\u30d5\u30a1\u30a4\u30eb<\/h3>\n<pre class=\"lang:default decode:true\">require 'common.php';\r\n\r\necho $val; \/\/\u5909\u6570\r\n\r\necho(\"&lt;br&gt;\");\r\necho(\"&lt;br&gt;\");\r\n\r\nkansu(); \/\/\u95a2\u6570<\/pre>\n<h2>include()<\/h2>\n<p>\u3082\u3057\u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u8fbc\u307f\u6642\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u3089\u8aad\u307f\u8fbc\u307f\u51e6\u7406\u304c\u505c\u6b62\u305b\u305a\u306b\u8b66\u544a\u304c\u767a\u751f\u3057\u307e\u3059\u3002<\/p>\n<h2>\u968e\u5c64\u304c\u7570\u306a\u308b\u5834\u5408<\/h2>\n<p>\u30d5\u30a9\u30eb\u30c0\u968e\u5c64\u304c\u7570\u306a\u308b\u5834\u5408\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<h3>\u968e\u5c64\u304c\u4e0b\u304c\u308b\u5834\u5408<\/h3>\n<pre class=\"lang:default decode:true\">require 'common\/common.php';<\/pre>\n<h3>\u968e\u5c64\u304c\u4e0a\u304c\u308b\u5834\u5408<\/h3>\n<pre class=\"lang:default decode:true \">require '..\/common\/common.php';<\/pre>\n<h2>require\u3068include\u306e\u3069\u3061\u3089\u304c\u826f\u3044\u304b\uff1f<\/h2>\n<p>\u5f8c\u7d9a\u51e6\u7406\u306b\u81f4\u547d\u7684\u306a\u5f71\u97ff\u304c\u3042\u308b\u5834\u5408\u306frequire\uff08\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u304c\u8981\u6c42\u3055\u308c\u308b\u30d0\u30c3\u30c1\u51e6\u7406\u306a\u3069\uff09\u3001\u753b\u9762\u51e6\u7406\u306a\u3069\u305d\u306e\u5834\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u3066\u3082\u5f8c\u7d9a\u306b\u5f71\u97ff\u304c\u306a\u3044\u5834\u5408\u306finclude\u3092\u4f7f\u3046\u306e\u304c\u826f\u3044\u3067\u3059\u3002<\/p>\n<p>\u753b\u9762\u3068\u304b\u3060\u3068\u5c11\u3057\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u3089\u518d\u958b\u304c\u5168\u304f\u3067\u304d\u306a\u304f\u306a\u308b\u3068\u56f0\u308b\u3068\u3044\u3046\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3002\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u7528\u9014\u3092\u7406\u89e3\u3057\u3066\u4f7f\u3044\u5206\u3051\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>\u30de\u30b8\u30c3\u30af\u5b9a\u6570<\/h2>\n<p>\u4e0b\u8a18\u306e\u5b9a\u6570\u3092\u5229\u7528\u3057\u3066\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u3092\u8a18\u8ff0\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002\u305d\u306e\u5834\u5408\u306f\u7d76\u5bfe\u30d1\u30b9\u6307\u5b9a\u306b\u306a\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<th>\u5b9a\u6570\u540d<\/th>\n<th>\u8aac\u660e<\/th>\n<\/tr>\n<tr>\n<td>__DIR__<\/td>\n<td>\u73fe\u5728\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u30d5\u30eb\u30d1\u30b9\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>__FILE__<\/div>\n<\/div>\n<\/td>\n<td>\u00a0\u73fe\u5728\u306e\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u3092\u30d5\u30a1\u30a4\u30eb\u540d\u3064\u304d\u3067\u8868\u793a\u3057\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td>__LINE__<\/td>\n<td>\u30d5\u30a1\u30a4\u30eb\u4e0a\u306e\u73fe\u5728\u306e\u884c\u756a\u53f7\u3002<\/td>\n<\/tr>\n<tr>\n<td>__FUNCTION__<\/td>\n<td>\u95a2\u6570\u540d\u3002\u7121\u540d\u95a2\u6570\u306e\u5834\u5408\u306f\u30af\u30ed\u30fc\u30b8\u30e3<\/td>\n<\/tr>\n<tr>\n<td>__CLASS__<\/td>\n<td>\u30af\u30e9\u30b9\u540d\u3002\u540d\u524d\u7a7a\u9593\u306b\u30af\u30e9\u30b9\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u5834\u5408\u306f\u540d\u524d\u7a7a\u9593\u3082\u542b\u307f\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td>__TRAIT__<\/td>\n<td>\u30c8\u30ec\u30a4\u30c8\u540d\u3002\u540d\u524d\u7a7a\u9593\u306b\u542b\u307e\u308c\u3066\u3044\u308b\u5834\u5408\u306f\u540d\u524d\u7a7a\u9593\u306e\u540d\u524d\u3082\u542b\u307f\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td>__METHOD__<\/td>\n<td>\u30af\u30e9\u30b9\u306e\u30e1\u30bd\u30c3\u30c9\u540d<\/td>\n<\/tr>\n<tr>\n<td>__NAMESPACE__<\/td>\n<td>\u73fe\u5728\u306e\u540d\u524d\u7a7a\u9593\u306e\u540d\u524d<\/td>\n<\/tr>\n<tr>\n<td>ClassName::class<\/td>\n<td>\u5b8c\u5168\u4fee\u98fe\u3055\u308c\u305f\u30af\u30e9\u30b9\u540d<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"PHP\u3067\u306e\u5916\u90e8\u306ePHP\u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u8fbc\u307f\u306f\u4e0b\u8a18\u306e\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002 require include \u540d\u524d\u7a7a\u9593 \u3069\u308c\u3067\u3082\u826f\u3044\u3067\u3059\u304c\u4e00\u822c\u7684\u306aPHP\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u306frequire\u304c\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u969b\u306b\u3061\u3083\u3093\u3068\u51e6\u7406\u304c\u6b62\u307e\u308b\u306e\u3067\u4e3b\u6d41\u306b\u306a [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[99,100],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/10390"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10390"}],"version-history":[{"count":13,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/10390\/revisions"}],"predecessor-version":[{"id":20335,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/10390\/revisions\/20335"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10390"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}