0
我正在使用方法一來替換值的字符串,並正常工作。我現在已經得到了自定義函數的手,所以我想將其更改爲方法2中更簡單的自定義函數方法,但它不起作用。任何幫助不勝感激。使用自定義函數str_replace內容
$plarge = $_POST['plarge'];
$phmaxl = $_POST['phmaxl'];
$fhandle = fopen($fname,"r");
$content = fread($fhandle,filesize($fname));
#### METHOD ONE ######
$content = str_replace($large,$plarge,$content);
$content = str_replace($hmaxl,$phmaxl,$content);
######################
#### METHOD TWO ######
function setreplace($set){
$content = str_replace($set,p.$set,$content);
}
setreplace($phmaxl);
setreplace($plarge);
#######################
####### WRITES NEW VAULUES TO SETTINGS FILE ############
$fhandle = fopen($fname,"w");
fwrite($fhandle,$content);
####### CLOSES SETTINGS FILE ############
fclose($fhandle);