The purpose of this proposal is to provide a set of common interfaces for HTTP messages as described in RFC 7230 and RFC 7231, and URIs as described in RFC 3986 (in the context of HTTP messages).
- RFC 7230: http://www.ietf.org/rfc/rfc7230.txt
| <?php | |
| if (isset($_POST['message'])) { | |
| file_put_contents('db.txt', $_POST['message']); | |
| $text = $_POST['message']; | |
| } else { | |
| $text = file_get_contents('db.txt'); | |
| } | |
| $text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8'); |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Facebook のログインサンプル (JavaScript)</title> | |
| <meta charset="UTF-8"> | |
| </head> | |
| <body> | |
| <script> | |
| window.fbAsyncInit = function() { | |
| FB.init({ |
| <?php | |
| $fb = new Facebook\Facebook([ | |
| 'app_id' => '{app-id}', | |
| 'app_secret' => '{app-secret}', | |
| 'default_graph_version' => 'v2.4', | |
| ]); | |
| $fb->setDefaultAccessToken($_SESSION['facebook_access_token']); | |
| $response = $fb->get('/me?locale=en_US&fields=name,email'); |
| <?php | |
| function timer(callable $block) { | |
| $start = microtime(true); | |
| for ($i = 0; $i < 100000; ++$i) { | |
| $block(); | |
| } | |
| $end = microtime(true); | |
| return $end - $start; | |
| } |
| <?php | |
| function timer(callable $block) { | |
| $start = microtime(true); | |
| for ($i = 0; $i < 100000; ++$i) { | |
| $block(); | |
| } | |
| $end = microtime(true); | |
| return $end - $start; | |
| } |
The purpose of this proposal is to provide a set of common interfaces for HTTP messages as described in RFC 7230 and RFC 7231, and URIs as described in RFC 3986 (in the context of HTTP messages).
| // http://stackoverflow.com/a/14947838/531320 | |
| const fromId = document.getElementById.bind(document); | |
| const snabbdom = require('snabbdom'); | |
| const patch = snabbdom.init([ | |
| require('snabbdom/modules/class'), | |
| require('snabbdom/modules/props'), | |
| require('snabbdom/modules/style'), | |
| require('snabbdom/modules/eventlisteners'), | |
| ]); |
| <?php | |
| $a = chr(0xfa).chr(0x4a); | |
| var_dump( | |
| "fa4a" === bin2hex($a) | |
| ); | |
| $a = mb_convert_encoding($a, "UTF-8", "CP932"); | |
| $a = mb_convert_encoding($a, "CP932", "UTF-8"); |
| <?php | |
| $a = chr(0xfa).chr(0x4a); | |
| var_dump( | |
| "fa4a" === bin2hex($a), | |
| "8754" === bin2hex(mb_strtolower($a, "CP932")), | |
| "8754" === bin2hex(mb_strtoupper($a, "CP932")) | |
| ); |
| <?php | |
| function utf8_ord($char) { | |
| $x = ord($char[0]); | |
| if ($x < 0x80) { | |
| return $x; | |
| } else if ($x < 0xE0) { | |
| $y = ord($char[1]); |