{"id":1898,"date":"2020-02-14T14:00:26","date_gmt":"2020-02-14T05:00:26","guid":{"rendered":"https:\/\/www.dogrow.net\/php\/?p=1898"},"modified":"2020-02-14T14:48:42","modified_gmt":"2020-02-14T05:48:42","slug":"blog67","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/php\/blog67\/","title":{"rendered":"(67) PHP\u3067\u30d5\u30a1\u30a4\u30eb\u306e\u7d76\u5bfe\u30d1\u30b9\u304b\u3089\u60c5\u5831\u3092\u62bd\u51fa"},"content":{"rendered":"<h1 class=\"my_h\">1. \u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>PHP\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u3044\u3066\u3044\u3066<br \/>\n<span class=\"my_fc_deeppinkBBig\">\u30d5\u30a1\u30a4\u30eb\u306e\u7d76\u5bfe\u30d1\u30b9\u304b\u3089\u4efb\u610f\u306e\u60c5\u5831\u3092\u62bd\u51fa\u3057\u305f\u3044<\/span><br \/>\n\u6642\u304c\u3042\u308b\u3002<\/p>\n<h1 class=\"my_h\">2. \u3084\u3063\u3066\u307f\u308b<\/h1>\n<h3 class=\"my_h\"><b>Case 1<\/b> : \u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30d1\u30b9\u306e\u672b\u7aef\u306e\u8981\u7d20\u3092\u53d6\u5f97\u3059\u308b\u3002<\/h3>\n<p>\u95a2\u6570 <span class=\"my_fc_deeppinkBBig\">basename<\/span> \u3067\u6307\u5b9a\u3057\u305f\u30d1\u30b9\u306e\u672b\u7aef\u306e\u8981\u7d20\u3092\u53d6\u5f97\u3067\u304d\u308b\u3002<\/p>\n<pre class=\"my_pre_python\">\r\necho <span class=\"my_fc_deeppinkB\">basename<\/span>(\"\/home\/hoge\/public_html\/www.dogrow.net\/test\/memo.txt\");\r\n<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002<br \/>\n\u30d5\u30a1\u30a4\u30eb\u306e\u7d76\u5bfe\u30d1\u30b9\u304b\u3089\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u53d6\u5f97\u3067\u304d\u305f\u3002<\/p>\n<pre class=\"my_pre\">\r\nmemo.txt\r\n<\/pre>\n<h3 class=\"my_h\"><b>Case 2<\/b> : \u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u540d\u3092\u53d6\u5f97\u3059\u308b\u3002<\/h3>\n<p>\u95a2\u6570 <span class=\"my_fc_deeppinkBBig\">dirname<\/span> \u3067\u6307\u5b9a\u3057\u305f\u30d1\u30b9\u306e\u672b\u7aef\u304b\u3089 n\u500b\u76ee\u306e\u89aa\u8981\u7d20\u3092\u53d6\u5f97\u3067\u304d\u308b\u3002<\/p>\n<pre class=\"my_pre_python\">\r\necho  <span class=\"my_fc_deeppinkB\">dirname<\/span>(\"\/home\/hoge\/public_html\/www.dogrow.net\/test\/memo.txt\");\r\n<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002<br \/>\n\u7b2c\u4e8c\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u6307\u5b9a\u3057\u306a\u304b\u3063\u305f\u5834\u5408\u306f\u4e00\u3064\u4e0a\u306e\u89aa\u8981\u7d20\u3092\u53d6\u5f97\u3059\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\n\/home\/hoge\/public_html\/www.dogrow.net\/test\r\n<\/pre>\n<p>\u7b2c\u4e8c\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3067\u3001<span class=\"my_fc_deeppinkBBig\">\u660e\u793a\u7684\u306b n\u756a\u76ee\u306e\u89aa\u8981\u7d20\u3092\u6307\u5b9a<\/span> \u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002<\/p>\n<pre class=\"my_pre_python\">\r\necho  <span class=\"my_fc_deeppinkB\">dirname<\/span>(\"\/home\/hoge\/public_html\/www.dogrow.net\/test\/memo.txt\", <span class=\"my_fc_deeppinkBBig\">1<\/span>);\r\necho  <span class=\"my_fc_deeppinkB\">dirname<\/span>(\"\/home\/hoge\/public_html\/www.dogrow.net\/test\/memo.txt\", <span class=\"my_fc_deeppinkBBig\">2<\/span>);\r\necho  <span class=\"my_fc_deeppinkB\">dirname<\/span>(\"\/home\/hoge\/public_html\/www.dogrow.net\/test\/memo.txt\", <span class=\"my_fc_deeppinkBBig\">3<\/span>);\r\n<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002<\/p>\n<pre class=\"my_pre\">\r\n\/home\/hoge\/public_html\/www.dogrow.net\/test\r\n\/home\/hoge\/public_html\/www.dogrow.net\r\n\/home\/hoge\/public_html\r\n<\/pre>\n<h3 class=\"my_h\"><b>Case 3<\/b> : \u6c4e\u7528\u30d1\u30b9\u60c5\u5831\u53d6\u5f97\u95a2\u6570 pathinfo \u3092\u4f7f\u3046\u3002<\/h3>\n<p>\u6c4e\u7528\u30d1\u30b9\u60c5\u5831\u53d6\u5f97\u95a2\u6570 <span class=\"my_fc_deeppinkBBig\">pathinfo<\/span> \u3092\u4f7f\u3046\u3068\u3001\u3044\u308d\u3044\u308d\u306a\u60c5\u5831\u3092\u307e\u3068\u3081\u3066\u53d6\u5f97\u3067\u304d\u308b\u3002<\/p>\n<pre class=\"my_pre_python\">\r\n$info = <span class=\"my_fc_deeppinkB\">pathinfo<\/span>(\"\/home\/hoge\/public_html\/www.dogrow.net\/test\/memo.txt\");\r\nvar_dump($info);\r\n<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002<br \/>\n\u8fd4\u3055\u308c\u305f\u9023\u60f3\u914d\u5217\u306b\u3044\u308d\u3044\u308d\u306a\u60c5\u5831\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\narray(4) { [\"dirname\"]=> string(42) \"\/home\/hoge\/public_html\/www.dogrow.net\/test\" [\"basename\"]=> string(8) \"memo.txt\" [\"extension\"]=> string(3) \"txt\" [\"filename\"]=> string(4) \"memo\" } \r\n<\/pre>\n<p>\u53d6\u5f97\u3057\u305f\u3044\u60c5\u5831\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u51fa\u6765\u308b\u3002<\/p>\n<pre class=\"my_pre_python\">\r\necho <span class=\"my_fc_deeppinkB\">pathinfo<\/span>(\"\/home\/hoge\/public_html\/www.dogrow.net\/test\/memo.txt\", <span class=\"my_fc_deeppinkB\">PATHINFO_DIRNAME<\/span>);\r\necho <span class=\"my_fc_deeppinkB\">pathinfo<\/span>(\"\/home\/hoge\/public_html\/www.dogrow.net\/test\/memo.txt\", <span class=\"my_fc_deeppinkB\">PATHINFO_BASENAME<\/span>);\r\necho <span class=\"my_fc_deeppinkB\">pathinfo<\/span>(\"\/home\/hoge\/public_html\/www.dogrow.net\/test\/memo.txt\", <span class=\"my_fc_deeppinkB\">PATHINFO_FILENAME<\/span>);\r\necho <span class=\"my_fc_deeppinkB\">pathinfo<\/span>(\"\/home\/hoge\/public_html\/www.dogrow.net\/test\/memo.txt\", <span class=\"my_fc_deeppinkB\">PATHINFO_EXTENSION<\/span>);\r\n<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002<\/p>\n<pre class=\"my_pre\">\r\n\/home\/hoge\/public_html\/www.dogrow.net\/test\r\nmemo.txt\r\nmemo\r\ntxt\r\n<\/pre>\n<h1 class=\"my_h\">3. \u5fdc\u7528<\/h1>\n<h3 class=\"my_h\">(1) \u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u540d\u524d\u3092\u53d6\u5f97\u3059\u308b\u3002<\/h3>\n<p>\u30ab\u30ec\u30f3\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u5b58\u5728\u3059\u308b memo.txt<br \/>\n<span class=\"my_fc_blueB\">\/home\/hoge\/public_html\/www.dogrow.net\/test\/memo.txt<\/span><br \/>\n\u306e\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u540d\u524d\u3092\u53d6\u5f97\u3059\u308b\u3002<\/p>\n<pre class=\"my_pre_python\">\r\n$str1 = <span class=\"my_fc_deeppinkB\">realpath<\/span>(\".\/memo.txt\");\r\n$str2 = <span class=\"my_fc_deeppinkB\">dirname<\/span>($str1);\r\n$str3 = <span class=\"my_fc_deeppinkB\">basename<\/span>($str2);\r\necho $str3;\r\n<\/pre>\n<pre class=\"my_pre_python\">\r\n$str = <span class=\"my_fc_deeppinkB\">basename<\/span>(<span class=\"my_fc_deeppinkB\">dirname<\/span>(<span class=\"my_fc_deeppinkB\">realpath<\/span>(\".\/memo.txt\")));\r\necho $str;\r\n<\/pre>\n<p>\u3069\u3061\u3089\u306e\u5834\u5408\u3082\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002<br \/>\nmemo.txt\u306e\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u540d\u304c\u53d6\u5f97\u3067\u304d\u3066\u3044\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\ntest\r\n<\/pre>\n<h1 class=\"my_h\">4. \u6240\u611f<\/h1>\n<p>\u30fb\u4eca\u5f8c\u3082\u3061\u3087\u304f\u3061\u3087\u304f\u60c5\u5831\u3092\u8ffd\u8a18\u3057\u3066\u3044\u3053\u3046\u3002<\/p>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>1. \u3084\u308a\u305f\u3044\u3053\u3068 PHP\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u3044\u3066\u3044\u3066 \u30d5\u30a1\u30a4\u30eb\u306e\u7d76\u5bfe\u30d1\u30b9\u304b\u3089\u4efb\u610f\u306e\u60c5\u5831\u3092\u62bd\u51fa\u3057\u305f\u3044 \u6642\u304c\u3042\u308b\u3002 2. \u3084\u3063\u3066\u307f\u308b Case 1 : \u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30d1\u30b9\u306e\u672b\u7aef\u306e\u8981\u7d20\u3092\u53d6\u5f97\u3059\u308b\u3002 \u95a2\u6570 basenam\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/php\/blog67\/\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-1898","post","type-post","status-publish","format-standard","hentry","category-23"],"views":1281,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/posts\/1898","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/comments?post=1898"}],"version-history":[{"count":16,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/posts\/1898\/revisions"}],"predecessor-version":[{"id":1915,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/posts\/1898\/revisions\/1915"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/media?parent=1898"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/categories?post=1898"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/tags?post=1898"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}