Oon virittelemässä tässä keskustelupalstaa vieraskirjan koodinpohjalta, mutta mitenkä saisin aina uuden txt tiedoston luotua kun kirjoittaja kirjottaa uuden ketjun..? Kyseessä ei voi olla mikään kovin helppo temppu, vai olenko väärässä?
Uuden tiedoston luominen (PHP)
Aloitteleva koodari
1312
0Äänestä
Muut lukivat myös
Odottaa vastausta
Näihin keskusteluihin ei ole vielä vastattu. Ole ensimmäinen.
Vastaukset 1
Vanhimmat
Periaatteessa näin
$fp = fopen ("/home/rasmus/file.txt", "a ");
jossa a voi olla muutakin tarpeen mukaan.
'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.
Serverin asetukset voi kuitenkin olla niin, että tiedoston ohjelmallinen luonti ei ole sallittua (kuten käyttämälläni serverillä on).