marshall: need help - php fopen

hi,

i've got a file called example.txt

with the command fopen i can open example.txt (read or write).

before i write a new line in example.txt, i want to delete the entire contents first.

how can i delete the contents?

the parameter w+ dosn't help, it only place the file pointer at the beginning of the file.

best whishes
marshall

  1. the parameter w+ dosn't help, it only place the file pointer at the beginning of the file.

    April fools?

    fopen()
    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.

    w+ does exactly what you want - i cannot reproduce your problem.

  2. echo $begrüßung;

    before i write a new line in example.txt, i want to delete the entire contents first.

    Did you read the content of the file before you are trying to write? The file pointer is now at the end of the file and needs to be repositioned to offset 0. Use fseek() or rewind().

    how can i delete the contents?

    To get rid of the old content an additional ftruncate() is needed.

    echo "$verabschiedung $name";