如何使用PHP删除JS注释?这个问题已更新:2013年11月4日回答:Alexander Yancharuk但是现在有一个问题.新代码:id = id.replace(/\//g,'');
这是我的例子:
<?php
$output = "
//remove comment
this1 //remove comment
this2 /* remove comment */
this3 /* remove
comment */
this4 /* * * remove
* * * *
comment * * */
this5 http://removecomment.com
id = id.replace(/\//g,''); //do not remove the regex //
";
$output = preg_replace( "/(?:(?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:(?<!\:)\/\/.*))/", "", $output ); //Yancharuk's code/regex
// "/(?<!\:)\/\/(.*)\\n/ = my oldest code
echo nl2br($output);
?>
Run Code Online (Sandbox Code Playgroud)
我的问题;
这是输出,最近:
this1
this2
this3
this4
this5 http://removecomment.com
ID = …
如何从这个函数ShowSC()添加睡眠
function ShowSC(){
$("#SC").html('LOADING');
//adding the sleep 1 second
$("#SC").html('<img src="secure/captcha/securimage_show.php" class="img_middle" />');
}
Run Code Online (Sandbox Code Playgroud)
提前感谢!
对不起,我找不到其他问题的解决方案,所以我在这里开始提问.
这是我的代码:
JS/jQuery的:
function RefreshImage(){
var form_data = {
ID: $('#ID').val()
};
$.ajax({
type: "POST",
url: "submit/image.php",
data: form_data,
success: function(data) {
$('#IMG').css('backgroundImage', "url('images/+data+')");
}
});
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<table>
<tr>
<td background="images/default.jpg" id="IMG"></td>
</tr>
</table>
<input type="hidden" id="ID" value="4">
Run Code Online (Sandbox Code Playgroud)
CSS:
#IMG{
background-color:rgba(0,0,0,0.5);
width:99px; height:99px;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
vertical-align:text-top;
}
Run Code Online (Sandbox Code Playgroud)
我的代码失败了,因为它只是变为黑色图像.但是在响应中,它显示了我请求的图像名称的确切值,但它失败了,因为它只是变为黑色.
提前谢谢.