我的PHP文檔末尾有一個變量,在頁腳中。但是,因爲它是模板,所以在每個頁面中創建變量的內容的方式不同。大多數變量的contect的是JS,這看起來是這樣的:用PHP放置JS var
$myVar = '
$(function() {
'.$qTip.'
$(".delDupe").click(function(){
$(this).parent().find("input").val("");
$(this).remove();
});
function custAxis() {
if ($("#axisChk").is(":checked")){
$(".customAxis").show();
} else {
$(".customAxis").hide();
}
}
custAxis();
});
這是所有JS的只是一個小片段。我想包含這個JS,仍然保留它作爲PHP變量的一部分,但在PHP之外。可能嗎?
$myVar = '?>
// my JS
<? ';
你試過了嗎?結果是什麼? – tkone 2012-04-19 01:25:23
聽起來像一個AJAX工作 – 2012-04-19 01:26:11
你的底部的例子,打破了一個PHP變量不能這樣做,它會被解釋爲一個字符串。我建議你使用heredoc – 2012-04-19 01:26:55