第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

PHP preg_replace - 文本不會(huì)被識(shí)別

PHP preg_replace - 文本不會(huì)被識(shí)別

PHP
幕布斯7119047 2021-11-26 17:41:48
我在使用 preg_replace 時(shí)遇到問(wèn)題。$insert_marker 文本將無(wú)法識(shí)別,并且是由“$”引起的。如果我刪除 2 $ 字符,它的工作原理。那么問(wèn)題出在哪里呢?function insert_into_file($file_path, $insert_marker, $text, $after = true) {    $contents = file_get_contents($file_path);    $new_contents = preg_replace($insert_marker, ($after) ? '$0' . $text : $text . '$0', $contents);    return file_put_contents($file_path, $new_contents);}$file_path = ".htaccess";$insert_marker = "/##-- $Id: _.htaccess 10934 2017-08-31 12:11:28Z serpent_driver $/";$text = "\n##added text";$num_bytes = insert_into_file($file_path, $insert_marker, $text, true);if ($num_bytes === false) {    echo "Could not insert into file $file_path.";} else {    echo "Insert successful!";}
查看完整描述

2 回答

?
吃雞游戲

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊

$是正則表達(dá)式的特殊字符(它意味著行尾),您必須對(duì)其進(jìn)行轉(zhuǎn)義:\$并且因?yàn)槟谑褂冒齽t表達(dá)式的變量并將其作為函數(shù)的參數(shù)傳遞,您必須進(jìn)行三次轉(zhuǎn)義:

$insert_marker = "/##-- \\\$Id: _.htaccess 10934 2017-08-31 12:11:28Z serpent_driver \\\$/";


查看完整回答
反對(duì) 回復(fù) 2021-11-26
?
森林海

TA貢獻(xiàn)2011條經(jīng)驗(yàn) 獲得超2個(gè)贊

理解你的問(wèn)題有點(diǎn)困難,但我發(fā)現(xiàn)你的意思是導(dǎo)致問(wèn)題的$Id部分$insert_marker。您需要使用反斜杠轉(zhuǎn)義 $,如下所示:$insert_marker = "/##-- \$Id: _.htaccess 10934 2017-08-31 12:11:28Z serpent_driver $/";


查看完整回答
反對(duì) 回復(fù) 2021-11-26
  • 2 回答
  • 0 關(guān)注
  • 212 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)