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 | 비밀글로 남기기

1 2 3 4 5 ... 153