Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   PHP, PERL, MySQL, JavaScript (https://forum.antichat.xyz/forumdisplay.php?f=37)
-   -   Проблема с fopen (https://forum.antichat.xyz/showthread.php?t=69708)

stigmatus 07.05.2008 19:37

Проблема с fopen
 
Цитата:

<html><body>
<form action="p2.php" method="post">
answer: <TEXTAREA NAME="answer" ROWS=40 COLS=40></TEXTAREA>
<input type="submit" />
</form>
<?

$ourFile = "answer.txt";
$ourFileH = fopen($ourFile, 'w') or die("can't open file");


$answer = $_POST['answer'];

fwrite($ourFileH, $answer . "\n");
fclose($ourFileH);

?>
</body></html>
------------------------------------------

Цитата:

<?php
$ourFile = "answer.txt";


$fh = fopen($ourFile, 'r');
$theData = fgets($fh);
fclose($fh);

echo $theData;

?>

проблема в том что когда пишу какоита текст и нажимаю enter о переводица в новую линию а когда читаю то enter нету и веси текст в однои линии !!

Naydav 07.05.2008 20:42

попробуй

fwrite($ourFileH, nl2br($answer) . "\n");

попугай 07.05.2008 20:50

пробуй \r\n

ENFIX 07.05.2008 21:28

попробуй открыть не блокнотом, а, например Notepad++

.:EnoT:. 07.05.2008 21:45

вы даже не поняли в чём тема.
PHP код:

<html><body>
<form action="" method="post">
answer: <textarea name="answer" rows=40 cols=40></textarea>
<input type="submit" />
</form>

<?php
$ourFile 
'answer.txt';
$ourFileH fopen($ourFile'a+') or die("can't open file");
$answer $_POST['answer'];
fwrite($ourFileH$answer."\n");
fclose($ourFileH);
?>
</body></html>

#######################

<?php
$ourFile 
'answer.txt';
$fh fopen($ourFile'r');
while(!
feof($fh))
{
   echo 
nl2br(fgets($fh4096));

fclose($fh);
?>

При чтении файла у него не переносился текст который записан в файле.

stigmatus 08.05.2008 00:01

.:EnoT:. pravilina !


Время: 14:32