当前位置:编程学习 > php >>

文件写入

//index.php 页面  
$incpeizhi="inc.peizhi.php"; 
$arr=array('mark_h','mark_w','mark_name','mark_url','mark_type'); 
extract($_POST); 
echo $mark_name; 
echo "<br>"; 
$configstr = ""; 
    foreach($arr as  $v) 
    {    
    echo $v;     
    ${$v} = str_replace("'","",${$v}); 
    $configstr .= "\${$v} = '".${$v}."';\r\n"; 
    } 
$configstr = "<"."?php\r\n".$configstr."?".">\r\n"; 
$fp=fopen($incpeizhi,"w"); 
fwrite($fp,$configstr); 
fclose($fp); 
 
//=======================  
//inc.peizhi.php 页面  
<?php 
$mark_h = '200'; 
$mark_w = '150'; 
$mark_name = 'xinxi'; 
$mark_url = 'www.zzzyk.com'; 
$mark_type = '1'; 
?> 
//===================  
//form页面  
<form action="index.php"  method="POST"> 
H:<input type="text" name="mark_h"><br> 
W:<input type="text" name="mark_w"><br> 
type:<input type="text" name="mark_type"><br> 
url:<input type="text" name="mark_url"><br> 
name:<input type="text" name="mark_name"><br> 
<input type="submit" value="submit"> 
</form> 

摘自 chaojie2009的专栏
补充:Web开发 , php ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,