3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /* GET リクエストでのシンプルなAPI */ //URLを指定 $url = "http://phplab.jp/"; $res = file_get_contents("http://api.b.st-hatena.com/entry.count?url=".$url); var_dump($res); echo $res; ?> <?php /* 被ブックマーク合計数取得API */ $request = xmlrpc_encode_request("bookmark.getTotalCount", $url); $context = stream_context_create(array('http' => array( 'method' => "POST", 'header' => "Content-Type: text/xml", 'content' => $request ))); $file = file_get_contents("http://b.hatena.ne.jp/xmlrpc", false, $context); $response = xmlrpc_decode($file); var_dump($response); echo $response; ?> <?php /* 50件以降も取得する 規制回避 */ function get_HB_favorited_counts(array $urls) { $ret = array_fill_keys($urls, false); $base_url = 'http://api.b.st-hatena.com/entry.counts'; foreach (array_chunk($urls, 50) as $set) { $query = '?' .implode('&', array_map(function ($url) { return 'url=' . rawurlencode($url); }, $set)); $res = json_decode(@file_get_contents($base_url . $query), true); if (is_array($res)) { foreach ($res as $url => $count) { $ret[$url] = $count; } } } return $ret; } $urls = array('http://codecanyon.net/', 'http://www.htaccesseditor.com/', 'http://phplab.jp/', 'http://www.php.net/', 'http://nicovideo.jp/', 'http://google.com/', 'http://google.co.jp/', 'http://example.com/', 'http://www.php.gr.jp/', 'http://php-users.jp/', 'http://aws.amazon.com/jp/php/', 'http://www.ioncube.jp/', 'http://amazon.com/', 'http://amazon.co.jp/', 'http://ameblo.jp/', 'http://blog.livedoor.com/', 'http://jugem.jp/', 'http://blog.fc2.com/', 'http://blog.seesaa.jp/contents/about/?via=a8', 'http://d.hatena.ne.jp/', 'http://blog.so-net.ne.jp/', 'http://www.ninja.co.jp/blog/', 'http://plaza.rakuten.co.jp/', 'http://blog.goo.ne.jp/', 'http://www.fruitblog.net/', 'http://www.exblog.jp/', 'http://blog.oricon.co.jp/', 'http://blogs.yahoo.co.jp/', 'http://ja.wordpress.com/', 'http://webryblog.biglobe.ne.jp/', 'http://www.yaplog.jp/', 'http://www.anisen.tv/', 'http://gamecs.jp/', 'http://www.eniblo.com/', 'http://blog.kuruten.jp/', 'http://iralog.net/', 'http://h.hatena.ne.jp/', 'http://www.foodlog.jp/', 'http://www.b-shoku.jp/', 'http://d-nikki.com/', 'http://a-thera.com/', 'http://blog.emachi.co.jp/blog/', 'http://www.areablog.jp/', 'http://www.2chiiki.jp/', 'http://www.zige.jp/', 'http://blog.qlep.com/', 'http://blog.goyah.net/', 'http://blog.saitamania.net/', 'http://fblg.jp/', 'https://arekao.jp/index.php?module=Profile&action=ShowRegistForm', 'http://sl.lcomi.ne.jp/mrs/', 'http://blog.k-plaza.com/', 'http://www.actiblog.com/' ); foreach (get_HB_favorited_counts($urls) as $key=>$c){ echo $key.'==>'.$c.'<br/>'; } echo 'Array count==>'.count($urls); ?>
Output for 7.0.0 - 7.0.3, 7.0.5 - 7.1.0
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/f7q9f on line 7 Warning: file_get_contents(http://api.b.st-hatena.com/entry.count?url=http://phplab.jp/): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/f7q9f on line 7 bool(false) Fatal error: Uncaught Error: Call to undefined function xmlrpc_encode_request() in /in/f7q9f:16 Stack trace: #0 {main} thrown in /in/f7q9f on line 16
Process exited with code 255.
Output for 7.0.4
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/f7q9f on line 7 Warning: file_get_contents(http://api.b.st-hatena.com/entry.count?url=http://phplab.jp/): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/f7q9f on line 7 bool(false) Fatal error: Uncaught Error: Call to undefined function xmlrpc_encode_request() in /in/f7q9f:16 Stack trace: #0 {main} thrown in /in/f7q9f on line 16
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Warning: Failed to open http://api.b.st-hatena.com/entry.count?url=http://phplab.jp/ (Could not resolve host: api.b.st-hatena.com) in /in/f7q9f on line 7 bool(false) Fatal error: Call to undefined function xmlrpc_encode_request() in /in/f7q9f on line 16
Process exited with code 255.
Output for 5.3.28 - 5.3.29, 5.4.20 - 5.4.41, 5.5.24 - 5.5.32, 5.5.34 - 5.6.17, 5.6.20 - 5.6.28
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/f7q9f on line 7 Warning: file_get_contents(http://api.b.st-hatena.com/entry.count?url=http://phplab.jp/): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/f7q9f on line 7 bool(false) Fatal error: Call to undefined function xmlrpc_encode_request() in /in/f7q9f on line 16
Process exited with code 255.
Output for 5.3.0 - 5.3.27, 5.4.0 - 5.4.19, 5.4.42 - 5.4.45, 5.5.33, 5.6.18 - 5.6.19
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/f7q9f on line 7 Warning: file_get_contents(http://api.b.st-hatena.com/entry.count?url=http://phplab.jp/): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/f7q9f on line 7 bool(false) Fatal error: Call to undefined function xmlrpc_encode_request() in /in/f7q9f on line 16
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/f7q9f on line 37
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/f7q9f on line 33
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_ARRAY, expecting ')' in /in/f7q9f on line 33
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_ARRAY, expecting ')' in /in/f7q9f on line 33
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/f7q9f on line 33
Process exited with code 255.