沃梦达 / 编程问答 / php问题 / 正文

PRIG_REPLACE FOR/*.*/

Preg_replace for /* ... */(PRIG_REPLACE FOR/*.*/)

本文介绍了PRIG_REPLACE FOR/*.*/的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的自定义模板系统创建OUTCOMMENT PRIG_REPLACE函数。

我尝试了以下方法:

// Outcomment
$pattern[] = "//*(.*?)/*/is";
$replace[] = "";

$content = preg_replace($pattern, $replace, $content);

但我不确定我是否完全理解preg_place的工作方式。

我正在尝试这样做,以便将删除/**/之间的所有内容。

推荐答案

尝试此操作:

$str = "Hello my name /* some comment */ is PHP /* and this comment*/ " ;       
$clean = preg_replace("//*(.*?)*//", "", $str) ;

echo $clean ; //Outputs Hello my name is PHP

这篇关于PRIG_REPLACE FOR/*.*/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:PRIG_REPLACE FOR/*.*/