This file contains 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 | |
/** | |
* curl_multiでHTTP複数リクエストを並列実行するテンプレ | |
* | |
*/ | |
//タイムアウト時間を決めておく | |
$TIMEOUT = 10; //10秒 | |
/* |
This file contains 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 | |
/** | |
* pecl-HTTPで並列リクエストを行うサンプル | |
* | |
*/ | |
$urls = array( | |
'http://localhost/sleep.php?wait=1', | |
'http://localhost/sleep.php?wait=2', | |
'http://localhost/sleep.php?wait=3', | |
); |
This file contains 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 | |
echo"引用符\n"; | |
$a = "変数\n"; | |
echo$a; |
This file contains 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 testRef(&$a) { | |
$a = 1; | |
} | |
testRef($b); | |
//$b === 1になる | |
call_user_func('testRef', $c); //エラー発生 | |
call_user_func('testRef', &$c); //deprecatedな書き方 |
This file contains 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 testRef(&$a) { | |
$args = func_get_args(); | |
$args[0] = 1; | |
} | |
testRef($a); | |
var_dump($a); //->null |
This file contains 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
var a = "global"; | |
with ({a:"local"}) { | |
console.log(a); //"local" | |
with ({a:"local2"}) { /* 入れ子にできる */ | |
console.log(a); //"local2" | |
} | |
console.log(a); //"local" | |
} | |
console.log(a); //"global" |
This file contains 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
function namespace(str) { | |
var names=str.split(".") | |
, i, l, cur = Function("return this")() | |
; | |
for (i=0,l=names.length; i<l; i++) { | |
cur[names[i]] = cur[names[i]] || {}; | |
cur = cur[names[i]]; | |
} | |
return cur; | |
} |
This file contains 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
var global = this; |
This file contains 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
function Class(c) { | |
if (c == null) { | |
c = function(){}; | |
} | |
c.extend = _extends; | |
c.mixin = _mixin; | |
c.statics = _static; | |
return c; | |
} | |
function _extends(uber) { |
This file contains 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 | |
class A { | |
} | |
$classname = 'A'; | |
$a = new A; //Aオブジェクト1 | |
$b = new $classname; //Aオブジェクト2 | |
$c = new $a; //Aオブジェクト3 |