(따옴표) Single쿼텐션 없애기 / 엔터 없애기 / GET방식 & 와 + 전송하기
Singe quote를 없애는 PHP함수는 addslashes를 많이 사용한다.
Ruby's 를 Ruby\'s 로 변환시켜준다.
$str
)Returns a string with backslashes before characters that need to be escaped. These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL
byte).
참고:
http://php.net/manual/en/function.addslashes.php
http://php.net/manual/en/function.mysql-real-escape-string.php
또하나 Javascript함수의 parameter로 문장중에 enter가 있으면 해당 명령이 실행되지 않습니다.
예) 다음과 같이 엔터가 있는 함수 처리 오류가 밸
<a href="#" onclick="setName(' Daniel
lee');" />
해당 엔터를 replace하기
This is a bit confusing
is there any php method to remove new line char from string?
It looks like you actually want them replaced with a space.
$str = str_replace(array("\r\n", "\n", "\r"), ' ', $str);
Assuming the replacing goes from left to right, this should suit Windows text files.
The first grouping is to match Windows newlines which use both \r and \n.
출처:
https://stackoverflow.com/questions/3200087/how-to-escape-new-line-from-string
GET방식으로 전송시 파라미터 값에 특수문자중에 & 와 +는 전송이되지 않는다.
전송하기 위해서는 변환을 해서 보내야하는데 그 전화하는 함수를 한번 만들어 봤으며 아스키코드값을 이용하거나 16진수값을 이용해보았다.
이용하기 위해서는 replace(param); 이렇게 함수를 호출하면 된다.
param = replace(param);
param2 = replace(param2);
http://host.com?num=param&num2=param2
/*------------------------------------------------------------------------------
* 함수명 : replace()
* 처리내용 : GET 전송시 특수문자함께 전송하는 방법
------------------------------------------------------------------------------*/
function replace(inum) {
inum = inum.replace(/&/g,"%26");
inum = inum.replace(/\+/g,"%2B");
return inum;
}
/*----------------------------------------------------------------------------*/
출처: http://www.joshi.co.kr/index.php?mid=board_XbwP90&listStyle=viewer&document_srl=293090&page=4