php教程

PHP修改文件内容示例教程

我的站长站 2022-08-15 人阅读

HTML提交表单代码:

<form name="form2" method="get" action="index.php" id="form2" onSubmit="return confirm('确认要操作?');">
  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
    <tr class="header"> 
      <td height="25" colspan="2">配置修改
      </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25"><div align="right">姓名:</div></td>
      <td height="25"><input name="name" type="text" id="name" value="<?=$fr[name]?>" size="80"></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td height="25"><div align="right">住址:</div></td>
      <td height="25"><input name="cid" type="text" id="cid" value="<?=$fr2[cid]?>" size="80"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">&nbsp;</td>
      <td height="25"><input type="submit" name="Submit" value="设置"> &nbsp;&nbsp;&nbsp; 
        <input type="reset" name="Submit2" value="重置"></td>
    </tr>
  </table>
</form>

php修改文件内容代码:

<?php
$name=$_GET['name'];
$cid=$_GET['cid'];

$newdata = <<<php
<?php
$name = '{$name}';
$cid = '{$cid}';
php;

file_put_contents("config.php",$newdata);
?>

config.php内容:

<?php
$name = '张三';
$cid = '武汉';
相关推荐
  • php修改文件
  • PHP批量修改数据库表前缀教程+代码

    有时候需要批量修改数据库表前缀,最简单的方法就是一个表一个表的手动修改,但是非常浪费时间。这里为大家分享一段自用的利用PHP批量修改数据库表前缀的方法,亲测可用,下面上代码。PHP修改表前缀代码<?php$dbserver=&#39;localhost&#39;;//连接的服务器...

    php教程 103 4年前
  • PHP同步修改配置文件示例教程+源码

    本教程是非常经典的PHP同步修改配置文件示例教程,非常适合新手朋友学习。主要学习了file_get_contents函数的读写方法,file_get_contents函数读取文件的方法,示例:$info=file_get_contents("文件路径");file_put_contents函数写入内容的方法,示例:file_put...

    php教程 36 1年前
  • PHP修改文件内容示例教程

    HTML提交表单代码:<form name="form2" method="get" action="index.php" id="form2" onSubmit="return confirm(&#39;确认要操作?&#39;);"> <table width="100%" border="0" align="cente...

    php教程 20 1年前
最新更新