-2
그래서 현재 다른 PHP 파일에 변수 (문자열이있는 문자열)를 POST하려고합니다.PHP에서 작은 따옴표를 이스케이프 처리 할 수 없습니다
변수는 SQL 요청 WHERE Row = 'something'
의 일부를 포함합니다.
내 변수 주위에 작은 따옴표를 넣으면 '뭔가'를 기대하지 않기 때문에 분명히 오류가 발생합니다. 그러나 큰 따옴표를 사용하면 'something'주위의 작은 따옴표가 큰 따옴표로 변경됩니다. 이 문자열을 게시하려면 어떻게해야합니까?
function getAJAXlink($count, $text) {
if (!empty($this->sqlVariable)) {
$addVarToLink = ", 'sqlVariable': '".$this->sqlVariable."' ";
}
if($this->contentDiv == '')
return '<a href="'. $this->anchorClass . ' ' . $this->baseURL . $count . '">'. $text .'</a>';
$pageCount = $count?$count:0;
$this->additionalParam = "{ 'page' : $pageCount $addVarToLink}";
return "<a href=\"javascript:void(0);\" " . $this->anchorClass . "
onclick=\"$.post('". $this->baseURL."', ". $this->additionalParam .", function(data){
$('#". $this->contentDiv . "').html(data); }); return false;\">"
. $text .'</a>';
}
function getAJAXlink($count, $text) {
if (!empty($this->sqlVariable)) {
$addVarToLink = ", 'sqlVariable': \"".$this->sqlVariable."\" ";
}
if($this->contentDiv == '')
return '<a href="'. $this->anchorClass . ' ' . $this->baseURL . $count . '">'. $text .'</a>';
$pageCount = $count?$count:0;
$this->additionalParam = "{ 'page' : $pageCount $addVarToLink}";
return "<a href=\"javascript:void(0);\" " . $this->anchorClass . "
onclick=\"$.post('". $this->baseURL."', ". $this->additionalParam .", function(data){
$('#". $this->contentDiv . "').html(data); }); return false;\">"
. $text .'</a>';
}
혼합 *** 네 ** 언어 * 코드 * 한 줄 그냥 문자열 인용 문제를 구걸 *에. 분명히 당신은 이것들을 어떻게 든 분리 할 수 있습니까? – David
PHP [HEREDOC] (http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc)를 사용해보십시오 – iyop45
당신은 모든 것을 두 번 인용해야하고 잊어 버려야합니다. 작은 따옴표. html로 작업 할 때 이것이 도움이된다는 것을 알았습니다. – McStuffins