PHP 싱글쿼테이션(') 및 특수문자 처리PHP 싱글쿼테이션(') 및 특수문자 처리

Posted at 2012/05/23 09:58 | Posted in Dev/PHP


DB에 Insert 나 Update 를 하다보면 


특수 문자로 인해 제대로 작동하지 않을때가 있다


이럴때는 특수문자앞에 \ or \ (역슬래시) 를 넣어주면 되는데 


이럴때 


addslashes()  

함수를 이용하면 된다.

$s = "aaa'aaa'aaa'aaa"
$s = addslashes($s) ;
결과 :aaa\'aaa\'aaa\'aaa

 위의 결과를 원래대로 돌려줄때는 

stripslashes()

함수를 이용하면 된다.


저작자 표시 비영리

Name __

Password __

Link (Your Website)

Comment

SECRET | 비밀글로 남기기

file_get_contents() Warning 오류 해결 방법file_get_contents() Warning 오류 해결 방법

Posted at 2012/05/22 11:33 | Posted in Dev/PHP

Warning: file_get_contents() URL file-access is disabled in the server configuration in

php.ini 파일을 수정하여 file_get_contents 기능을 사용할수 있지만...

웹호스팅을 이용할 경우 php.ini 수정이 어렵다.

하지만, 오류를 해결하는 방법으로 외부 파일을 읽어 들이는 함수 이용전에

ini 설정을 임시로 변경해서 사용하면 된다.

@ini_set("allow_url_fopen","1");


저작자 표시 비영리

Name __

Password __

Link (Your Website)

Comment

SECRET | 비밀글로 남기기

[PHP] 이미지에 텍스트 합성 하기[PHP] 이미지에 텍스트 합성 하기

Posted at 2012/04/05 23:51 | Posted in Dev/PHP


GD 라이브러리가 설치 되어 있어야 사용이 가능합니다.

$text1 = "테스트테스트

    테스트테스트

    테스트테스트";  


 $text2 = "

    testestestest

    testestestest

    testestestest";  


 $text3 = "

    ★■

    ★■

    ★■";  


$stext1 = iconv("EUC-KR", "UTF-8", $text1);  //한글 특문 깨짐 방지

$stext2 = iconv("EUC-KR", "UTF-8", $text2); //한글 특문 깨짐 방지

$stext3 = iconv("EUC-KR", "UTF-8", $text3); //한글 특문 깨짐 방지


    $fsize = 10; #font size 12 pixels  // 폰트 크기


    $ttf  ="./MALGUN.TTF"; // 폰트 위치


    $img = imagecreatefromjpeg('test1.jpg');  // 바탕이 될 이미지


    $textColor = imagecolorallocate($img, 120, 150, 0); // 텍스트 색 지정


imagettftext($img, $fsize, 5, 90, 85, $textColor, $ttf, $stext1);    // 이미지에 글쓰기

imagettftext($img, $fsize, 0, 410, 85, $textColor, $ttf, $stext2); // 이미지에 글쓰기

imagettftext($img, $fsize, 10, 710, 85, $textColor, $ttf, $stext3);  // 이미지에 글쓰기

            

   imagejpeg($img,"./test1_text.jpg",85); // 이미지 저장


저작자 표시 비영리

Name __

Password __

Link (Your Website)

Comment

SECRET | 비밀글로 남기기

date() [function.date]: It is not safe to rely on the system's timezone settings.date() [function.date]: It is not safe to rely on the system's timezone settings.

Posted at 2011/11/01 15:17 | Posted in Dev/PHP
Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for '9.0/no DST'

PHP 를 처음 접해 보는데 

이 에런 무엇인가 -_-;;;
 
Date를 아시아로 설정하라는거 같은데

어떻게 하는걸까 -_-;; 

이럴 경우에 php.ini 를 아래 와 같이 수정

없으면 추가

[Date]
date.timezone  = Asia/Seoul





저작자 표시 비영리

Name __

Password __

Link (Your Website)

Comment

SECRET | 비밀글로 남기기