{"id":9647,"date":"2018-09-08T21:14:15","date_gmt":"2018-09-08T12:14:15","guid":{"rendered":"https:\/\/www.itblog.jp\/?p=9647"},"modified":"2018-09-08T21:14:15","modified_gmt":"2018-09-08T12:14:15","slug":"file_get_contents%e3%81%8cnull%e3%82%92%e8%bf%94%e3%81%99%e3%82%88%e3%81%86%e3%81%ab%e3%81%aa%e3%81%a3%e3%81%9f%e5%8e%9f%e5%9b%a0%e3%81%ae%e8%aa%bf%e6%9f%bb","status":"publish","type":"post","link":"https:\/\/www.itblog.jp\/?p=9647","title":{"rendered":"file_get_contents\u304cNULL\u3092\u8fd4\u3059\u3088\u3046\u306b\u306a\u3063\u305f\u539f\u56e0\u306e\u8abf\u67fb"},"content":{"rendered":"<p>PHP\u3067\u3001\u3042\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3057\u3066\u3044\u3066\u3001file_get_contents\u95a2\u6570\u3067\u7279\u5b9a\u306eURL\u304b\u3089JSON\u30d5\u30a1\u30a4\u30eb\u3092\u53d6\u5f97\u3059\u308b\u3068\u3044\u3046\u51e6\u7406\u3092\u884c\u3063\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u4ee5\u524d\u306f\u52d5\u4f5c\u3057\u3066\u3044\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u3001\u30b5\u30fc\u30d0\u79fb\u884c\u5f8c\u306b file_get_contents\u95a2\u6570\u3067\u53d6\u5f97\u3067\u304d\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3063\u305f\u73fe\u8c61\u306b\u906d\u9047\u3057\u3066\u3057\u307e\u3063\u305f\u306e\u3067\u8abf\u67fb\u3068\u5bfe\u5fdc\u306b\u3064\u3044\u3066\u8a18\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<h2>\u72b6\u6cc1<\/h2>\n<p>\u30fb\u3000\u7279\u5b9a\u306eURL\u304b\u3089 file_get_contents\u95a2\u6570\u3067JSON\u30d5\u30a1\u30a4\u30eb\u3092\u53d6\u5f97\u3057\u3001\u5f8c\u306b\u51e6\u7406<\/p>\n<p>\u30fb\u3000\u4ee5\u524d\u306f\u52d5\u4f5c\u3057\u3066\u3044\u305f\u304c\u3001\u30b5\u30fc\u30d0\u79fb\u8ee2\u5f8c\u306b\u52d5\u4f5c\u3057\u306a\u304f\u306a\u3063\u305f<\/p>\n<p>\u30fb\u3000\u30ec\u30b9\u30dd\u30f3\u30b9\u30d8\u30c3\u30c0\u3082NULL\u3092\u8fd4\u3059\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u3066\u3001\u539f\u56e0\u304c\u4e0d\u660e<\/p>\n<h2>\u8abf\u67fb<\/h2>\n<p>\u307e\u305a\u3001\u30a8\u30e9\u30fc\u30ed\u30b0\u3092\u898b\u3066 file_get_contents \u95a2\u6570\u304c\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3044\u306a\u3044\u304b\u3069\u3046\u304b\u3092\u8abf\u3079\u3066\u307f\u305f\u306e\u3067\u3059\u304c\u3001\u30a8\u30e9\u30fc\u306b\u306f\u306a\u3063\u3066\u3044\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n<p>\u7d50\u679c\u304b\u3089\u3044\u3046\u3068\u3001\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3044\u305f\u308f\u3051\u3067\u306f\u306a\u304f\u3001\u53d6\u5f97\u304cNULL\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u3044\u3046\u8b0e\u306e\u7d50\u679c\u3002<\/p>\n<h2>\u89e3\u6c7a<\/h2>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u53d6\u5f97\u3059\u308b\u306e\u306b\u3001file_get_contents\u95a2\u6570\u3067\u306f\u306a\u304f\u3001cURL\u95a2\u6570\u3092\u4f7f\u3046\u3053\u3068\u3067\u89e3\u6c7a\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u8a18\u4e8b\u304c\u53c2\u8003\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"https:\/\/www.tam-tam.co.jp\/tipsnote\/program\/post8753.html\" rel=\"noopener\" target=\"_blank\">file_get_contents\u95a2\u6570\u304c\u52d5\u304b\u306a\u304b\u3063\u305f\u5834\u5408\u306e\u65b9\u6cd5 \uff5c Tips Note by TAM<\/a><\/p>\n<p>cURL\u95a2\u6570\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001file_get_contents\u3068\u307b\u307c\u540c\u3058\u52d5\u4f5c\u3092\u3059\u308b\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u3001\u4f7f\u7528\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:default decode:true \" >$result = curl_get_contents( $url, 120 );  \/\/file_get_contents\u306e\u4ee3\u7528\u95a2\u6570\u3002120\u306f\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8(\u79d2)\r\n \r\nfunction curl_get_contents( $url, $timeout ){\r\n    $ch = curl_init();\r\n    curl_setopt( $ch, CURLOPT_URL, $url );\r\n    curl_setopt( $ch, CURLOPT_HEADER, false );\r\n    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );\r\n    curl_setopt( $ch, CURLOPT_TIMEOUT, $timeout );\r\n    $result = curl_exec( $ch );\r\n    curl_close( $ch );\r\n    return $result;\r\n}<\/pre>\n<p>\u4f55\u6545 file_get_contents \u95a2\u6570\u304c\u65b0\u3057\u3044\u30b5\u30fc\u30d0\u3067\u52d5\u4f5c\u3057\u306a\u304b\u3063\u305f\u306e\u304b\u306b\u3064\u3044\u3066\u306f\u4e0d\u660e\u3067\u3059\u304c\u3001\u4ee3\u7528\u306e\u95a2\u6570\u3067\u306a\u3093\u3068\u304b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP\u3067\u3001\u3042\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3057\u3066\u3044\u3066\u3001file_get_contents\u95a2\u6570\u3067\u7279\u5b9a\u306eURL\u304b\u3089JSON\u30d5\u30a1\u30a4\u30eb\u3092\u53d6\u5f97\u3059\u308b\u3068\u3044\u3046\u51e6\u7406\u3092\u884c\u3063\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u4ee5\u524d\u306f\u52d5\u4f5c\u3057\u3066\u3044\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u3001\u30b5\u30fc\u30d0\u79fb\u884c\u5f8c\u306b file_get_ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[144,131],"tags":[],"class_list":["post-9647","post","type-post","status-publish","format-standard","hentry","category-php-","category-131"],"_links":{"self":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/9647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9647"}],"version-history":[{"count":0,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/9647\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}