Jump to content
php.lv forumi

web mail


xfr33

Recommended Posts

  • Replies 47
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

tātad lietojot fopen var atvērt failu, kuru izmainīt var ar fwrite? un kā pēc tam saglabāt? nevar katru reizi jaunu failu taisīt? un likt viņus visus mapē kuru es nodefinēju!

Link to comment
Share on other sites

šis te piemērs

<?php
$fp = fopen('data.txt', 'w');
fwrite($fp, '1');
fwrite($fp, '23');
fclose($fp);

// the content of 'data.txt' is now 123 and not 23!
?>

 

cik noprotu tad atver failu data.txt un pieliek klāt 123 un pēc tam aizver. pareizi sapratu? tas kas jau ir tai failā bijis ierakstīts tas paliek tur?

Link to comment
Share on other sites

Nē, nepaliek.

Skaties te:

http://lv.php.net/manual/en/function.fopen.php

A list of possible modes for fopen() using mode mode Description

'r' Open for reading only; place the file pointer at the beginning of the file.

'r+' Open for reading and writing; place the file pointer at the beginning of the file.

'w' Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.

'w+' Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.

'a' Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.

'a+' Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it.

'x' Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call.

'x+' Create and open for reading and writing; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call.

Link to comment
Share on other sites

ok man tagad tiek viss rakstīts failā data.txt! ņēmu to "a"! kā var izveidot jaunu failu pie katras jaunas atvēršanas? tikai lai faila nosaukums visu laiku būtu teiksim tās firmas nosaukums ( iepriekšējā formā tiek ievadīts firmas nosaukums )? :)

Link to comment
Share on other sites

nu tātad man aizpildot formu esmu sataisijis lai taisa jaunus failus ar pareizajiem nosaukumiem un ta talāk, bet vajadzigs sekojošais:

1. ieiet lapā, aizpilda formu.

2. aiziet uz nākamo lapu, kura izveido jaunu txt failu

3. neko nespiežot iet uz manis nodefinētu lapu!

trešo punktu nemāku :( :D

Link to comment
Share on other sites

nu cmon šito kodu es zināju, bet kad ierakstu man rādas kļūda!

Kļūda

Warning: Cannot modify header information - headers already sent by (output started at C:\WEB\htdocs\write.php:12) in C:\WEB\htdocs\write.php on line 17

Link to comment
Share on other sites


×
×
  • Create New...