Google
 

« MySQL | メイン | Perl »

2009年07月28日

●UTF-8をSJISに変換

htaccess
php_flag output_buffering On
php_value output_handler mb_output_handler
php_value default_charset Shift_JIS
php_value mbstring.language Japanese
php_flag mbstring.encoding_translation On
php_value mbstring.http_input auto
php_value mbstring.http_output Shift_JIS
php_value mbstring.internal_encoding UTF-8
php_value mbstring.substitute_character none

続きを読む "UTF-8をSJISに変換"
2009年07月25日

●eaccelerator

wget http://nchc.dl.sourceforge.net/sourceforge/eaccelerator/eaccelerator-0.9.5.tar.bz2
bunzip2 eaccelerator-0.9.5.tar.bz2
tar xvf eaccelerator-0.9.5.tar -C /usr/local/src
cd /usr/local/src/eaccelerator-0.9.5
phpize


./configure --enable-eaccelerator=shared --with-php-config=/usr/bin/php-config --with-eaccelerator-info

make
make install
cp ./modules/eaccelerator.so /usr/lib/php/extensions/


php.ini

zend_extension = "/usr/lib/php/extensions/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.log_file = "/var/log/eaccelerator_log"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
eaccelerator.allowed_admin_path="/home/kimchi/html/control.php"

2009年05月11日

●XdebugとWinCacheGrind

XdebugとWinCacheGrind

2009年03月18日

●HTMLでPHP

AddHandler php5-script .php .html .htm
AddType text/html .php .html .htm
AddType application/x-httpd-php .htm .html

2009年03月07日

●PEAR アップデート

# pear channel-update pear.php.net

# pear upgrade PEAR

2009年01月19日

●mb_convert_kana

表 1. 使用可能な変換オプション

オプション 意味
r 「全角」英字を「半角」に変換します。
R 「半角」英字を「全角」に変換します。
n 「全角」数字を「半角」に変換します。
N 「半角」数字を「全角」に変換します。
a 「全角」英数字を「半角」に変換します。
A 「半角」英数字を「全角」に変換します ("a", "A" オプションに含まれる文字は、U+0022, U+0027, U+005C, U+007Eを除く U+0021 - U+007E の範囲です)。
s 「全角」スペースを「半角」に変換します(U+3000 -> U+0020)。
S 「半角」スペースを「全角」に変換します(U+0020 -> U+3000)。
k 「全角カタカナ」を「半角カタカナ」に変換します。
K 「半角カタカナ」を「全角カタカナ」に変換します。
h 「全角ひらがな」を「半角カタカナ」に変換します。
H 「半角カタカナ」を「全角ひらがな」に変換します。
c 「全角カタカナ」を「全角ひらがな」に変換します。
C 「全角ひらがな」を「全角カタカナ」に変換します。
V 濁点付きの文字を一文字に変換します。"K", "H" と共に使用します。


例 1. mb_convert_kana() の例

/* 「仮名」を全て「全角カタカナ」に変換します */
$str = mb_convert_kana($str, "KVC");

/* 「半角カタカナ」を「全角カタカナ」に変換し、「全角」英数字を「半角」
に変換します。 */
$str = mb_convert_kana($str, "KVa");
?>

2008年08月27日

●Maximum execution time of 30 seconds exceededの対応方法

set_time_limit(60);

2007年11月27日

●array_search

array_search -- 指定した値を配列で検索し、見つかった場合に対応するキーを返す


$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');

$key = array_search('green', $array); // $key = 2;
$key = array_search('red', $array); // $key = 1;

2007年11月16日

●環境変数表示

#!/usr/bin/perl

print "Content-type: text/html\n\n

";
foreach (sort keys %ENV) { print "$_ = $ENV{$_}\n"; }
print "
\n";

2007年09月27日

●PDFlib

PHP拡張モジュールをコピーし、php.iniに拡張モジュールエントリを追加します。

bind/php/php-43x/libpdf_php.so

# cp bind/php/php-43x/libpdf_php.so /usr/local/lib/php/20070927/

extension_dir = /usr/local/lib/php/20070927/

extension = libpdf_php.so

2007年09月14日

●check_rbl2.php

function check_spammer(){
$re_flg = 0;
$ip = getenv("REMOTE_ADDR");
if($ip == "127.0.0.1")
$ip = "$HTTP_X_FORWARDED_FOR";

if(preg_match("/^([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})$/", $ip, $matches)){
$q1 = $matches[1];
$q2 = $matches[2];
$q3 = $matches[3];
$q4 = $matches[4];
$ip = "$q4.$q3.$q2.$q1";
}else{
}

// check list.dsbl.org, all.rbl.jp
$i = 0;
$check_list = array(".list.dsbl.org", ".all.rbl.jp");
while($i < count($check_list)){
$check = $ip . $check_list[$i];
$i ++;

$result = gethostbyname($check);

if ($result != $check) {
$re_flg = 1;
break;
} else {
}
}

return $re_flg;
}

?>

2007年09月01日

●SQLite

tar -xzvf php-4.4.7.tar.gz
tar -xzvf SQLite-1.0.3.tgz
mv SQLite-1.0.3 php-4.4.7/ext/sqlite
cd php-4.4.7
rm configure
./buildconf --force

./configure --with-sqlite
make
make install


2007年08月23日

●configureオプション

FreeTypeの場合は「--with-ttf」、FreeType2の場合は「--with-freetype-dir」のオプションが必要です。


続きを読む "configureオプション"