首页 > 其他 > 网站日记>正文

如何去掉php文件中的注释

提示: 阅读权限:公开  

php文件中的注释有三种:

  1. 连续的两个斜杠,到换行部分---(//.*?n) 

  2. #开头,到换行部分---(#.*?n)

  3. /*中间是注释*/---(/*.*?*/)

所以可以用下边的正则完成注释的删除

function removeComment($content){
    $content=str_replace(array("rn", "r"), "n", $content);
    return preg_replace("/(/*.*?*/)|(#.*?n)|(//.*?n)/s",'', $content);
}

代码以图片为准:

上一篇:帝国小欧使用教程

下一篇:过滤微信昵称中的特殊字符

tags: php 编程语言 图片

返回首页

相关

热门

站内直通车

[!--temp.bottomnav--]
返回顶部