php iconv 사용 할 수 없을때.

// build iconv function
//http://monowx.blog.me/110084374548
if(!function_exists('iconv')) {
	function iconv($from, $to, $text) {
		$tmp_from = $_SERVER['DOCUMENT_ROOT'].'/temp/iconv_from';
		$tmp_to = $_SERVER['DOCUMENT_ROOT'].'/temp/iconv_to';
		$iconv_path = "/usr/bin/iconv";

		if(file_exists($tmp_from)) {
			@unlink($tmp_from);
		}
		if(file_exists($tmp_to)) {
			@unlink($tmp_to);
		}

		$open_from = fopen($tmp_from, "w");
		fwrite($open_from, $text);
		fclose($open_from);

		exec($iconv_path." -f ".$from." -t ".$to." ".$tmp_from." > ".$tmp_to);

		$oepn_to = fopen($tmp_to, "a+");
		$text = @fread($oepn_to, filesize($tmp_to));
		fclose($oepn_to);

		unlink($tmp_from);
		unlink($tmp_to);

		return $text;
	}
}

'PHP' 카테고리의 다른 글

압축해서 다운로드 받기  (0) 2011.11.10
phpThumb() 이미지 변환기  (0) 2011.07.28
if($a = $b)  (0) 2010.05.10
ASP / PHP Cross Reference  (0) 2010.04.14
캐쉬 사용 함수 캐쉬 삭제 clearstatcache 사용 간편하게.  (0) 2009.10.15