在php中怎样修改配置文件
在php中怎样修改配置文件?
在php中修改配置文件的方法:
一、先修改引导页<?php
include("dbconfig.php");
?>
端口:
用户名:
密码:
数据库名:
二,修改页面<?php
//获取配置文件的内容
$string = file_get_contents('config.php');
foreach ($_POST as $key=>$value) {
//正则匹配对应的一行
$old_inf = "/define\('$key','.*?'\);/";
//要修改成的数据
$new_inf = "define('$key','$value');";
//替换
$string = preg_replace($old_inf,$new_inf,$string);
}
//写入配置文件
file_put_contents('config.php',$string);
echo "修改成功";
推荐教程:《PHP视频教程》
在php中怎样修改配置文件?的教程已介绍完毕,更多请关注跳墙网其他文章教程!
在php中怎样修改配置文件相关教程