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 | |
| class Server { | |
| /** _parse */ | |
| private static function _parse( $str ) { | |
| $ret = array(); | |
| if ($str !== '') { | |
| foreach( explode( '&', $str ) as $data ) { | |
| $tmp = explode( '=', $data ); | |
| $ret[urldecode($tmp[0])] = urldecode($tmp[1]); |
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 | |
| $file_path = './sample.jpg'; | |
| $cascade = './haarcascade_frontalface_alt.xml'; | |
| $faces = face_detect( $file_path, $cascade ); | |
| if ( ! count( $faces ) ) { | |
| exit( '顔がない' ); | |
| } | |
| $img = imagecreatefromjpeg( $file_path ); | |
| $line_color = imagecolorallocate( $img, 255, 0, 0 ); |
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
| function FlashPlayerVer() { | |
| var flashplayer_ver = 0; | |
| if(navigator.plugins && navigator.mimeTypes['application/x-shockwave-flash']){ | |
| var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin; | |
| if(plugin){ | |
| flashplayer_ver = parseInt(plugin.description.match(/\d+\.\d+/)); | |
| } | |
| } else { | |
| try{ | |
| var flashOCX = new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version").match(/([0-9]+)/); |
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 | |
| $param = 'aaa'; | |
| $list = array('aaa','bbb','ccc','ddd','eee'); | |
| echo in_array( $param, $list, true ) ? 'OK' : 'NG'; |
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
| #!/usr/bin/perl | |
| use strict; | |
| use warnings; | |
| my ( $a, $b ) = unko(); | |
| print "$a\n"; | |
| print "$b\n"; | |
| sub unko { | |
| return ( 'aaa', 'bbb' ); |
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
| RewriteEngine On | |
| # スマホとか | |
| BrowserMatchNoCase "(iPhone)|(iPod)|(Android)" ua-type=sumaho | |
| RewriteCond %{ENV:ua-type} "sumaho" | |
| RewriteRule ^.*$ http://www.example.com/sumaho/ [R=302,L] | |
| # ガラケーとか | |
| BrowserMatchNoCase "(DoCoMo)|(KDDI)|(Up\.Browser)|(J\-PHONE)|(Vodafone)|(SoftBank)|(MOT\-[VC])|(Vemulator)" ua-type=keitai | |
| RewriteCond %{ENV:ua-type} "keitai" |
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
| var data = { | |
| '16' : 'こ', | |
| '15' : 'め', | |
| '14' : 'を', | |
| '13' : 'と', | |
| '12' : 'ぎ', | |
| '11' : 'と', | |
| '10' : 'ぎ' | |
| }; | |
| var buf = ''; |
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 | |
| $a = [ 1, 2, 3 ]; | |
| print_r( $a ); | |
| $a = [ 'unko' => 'うんこ', 'geri' => 'ゲリ' ]; | |
| print_r( $a ); | |
| /* | |
| Array | |
| ( | |
| [0] => 1 |
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 test_apache( $host ){ | |
| $bytes = '0-10000,1-10001,2-10002,3-10003,4-10004,5-10005'; | |
| $def = stream_context_get_default( | |
| array( | |
| 'http'=>array( | |
| 'method' => "HEAD", | |
| 'protocol_version' => "1.1", | |
| 'header' => "Range:bytes={$bytes}\r\n". |
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 | |
| $json_str = '{"hoge":"ほげ", "fuga":"ふが"}'; | |
| $json = json_decode( $json_str ); | |
| echo $json->hoge; // ほげ | |
| echo $json->fuga; // ふが |