php改动配备文档的案例
作者:admin 发布时间:2020-08-05
评价:edit.php 载入config.php文档,将这一文档视作标识符串。我随后应用正则表达式表述示配对来改动內容。
?php
$string=file_get_contents( #39;config.php #39;);
...t.php 载入config.php文档,将这一文档视作标识符串。我随后应用正则表达式表述示配对来改动內容。
$string=file_get_contents(config.php);
//DB_HOST loCAlhost
foreach($_POST as $key= $val){
//界定正则表达式来搜索內容,这儿面的key为form表格里边的name
$yx= /define\( $key , .*? /
//将內容配对成相匹配的key和改动的值
$re= define( $key , $val
//更换內容
$string=preg_replace($yx,$re,$string);
}
//载入取得成功
file_put_contents( config.php ,$string);
echo 改动取得成功