您的位置:首页 > 编程语言 > PHP开发

php如何写入文件

2010-10-19 13:12 232 查看
/*<html>
<head>
<title>
</title>
</head>
<body>*/
<?
if(isset($_POST['submitted'])){
 if(!empty($_POST['quote'])&&($_POST['quote']!='Enter your quotion here.')){
  if($fp = fopen('../quotex.txt','ab')){
   //stream_encoding($fp,'utf-8');
   fwrite($fp,"{$_POST['quote']}/n");
   fclose($fp);
   print"<p>Your quotation has been stored.</p>";
  }else{
   print '<p>style = "color:red;">Your quotation could not be stored due to a systeme error.</p>';

  }
 }else{
   print '<p>style = "color:red:">Please enter a quotation!</p>';
   }
}
?>
<form action = "add_quote.php" method = "post">
 <textarea name = "quote" row = 5 cols = "30" >enter your quotation here.</textarea>
 <input type = "submit" name = "submit" value = "Add the quote"/>
 <input type = "hidden" name = "submitted" value = "true" />
</form>
</body>
</html>
摘抄自《php基础教程》

当文件不存在时,可以建立文件。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php fp encoding action