0
我想用php變量替換RewriteCondition中的服務器變量。
forexampe:
我有以下字符串:
$x="RewriteCond %{HTTP_HOST} ^www";
我想是$ var ==
$x="RewriteCond %{HTTP_HOST} ^www";
preg_replace("/%\{[^}]+)\}/i","$$1==",$x);
上面的代碼是不工作來代替%{VAR},我收到來自php正則表達式解析器的警告:
compilation failed, unmatched parentheses at offset at
我試圖用反斜槓替換$,但它也沒有解決問題。
功能有問題嗎?
您是否嘗試過配對? –
'preg_replace(「/ \%\ {[^ \}] + \}/i」,「$$ 1 ==」,$ x)' – roullie