This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function timer(callable $block) { | |
$start = microtime(true); | |
for ($i = 0; $i < 100000; ++$i) { | |
$block(); | |
} | |
$end = microtime(true); | |
return $end - $start; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function timer(callable $block) { | |
$start = microtime(true); | |
for ($i = 0; $i < 100000; ++$i) { | |
$block(); | |
} | |
$end = microtime(true); | |
return $end - $start; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Facebook のログインサンプル (JavaScript)</title> | |
<meta charset="UTF-8"> | |
</head> | |
<body> | |
<script> | |
window.fbAsyncInit = function() { | |
FB.init({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
$login = isset($_POST['username']) | |
&& $_POST['username'] === 'myuser' | |
&& isset($_POST['password']) | |
&& $_POST['password'] === 'mypass'; | |
$logout = isset($_POST['logout']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$user = json_decode(file_get_contents('user.json'), true); | |
if (isset($_POST['email'])) { | |
$email = $_POST['email']; | |
$msg = '更新しました。'; | |
$user = ['email' => $email]; | |
file_put_contents('user.json', json_encode($user)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'functions.php'; | |
header('Content-Type: application/json'); | |
$id = empty($_POST['id']) ? null : (int) $_POST['id']; | |
$amount = empty($_POST['amount']) ? null : (int) $_POST['amount']; | |
if (!is_int($id) || 0 > $id) { | |
echo json_encode([ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function timer(callable $block) { | |
$start = microtime(true); | |
for ($i = 0; $i < 100000; ++$i) { | |
$block(); | |
} | |
$end = microtime(true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/i18next/1.6.3/i18next-1.6.3.min.js"></script> | |
<script> | |
var resources = { | |
en: { | |
translation: { | |
"content": { | |
"access": "Access" | |
} |