'r' (read only, file pointer at the beginning)
'r+' (read and write, file pointer at the beginning)
'w' (write only, file pointer at the beginning, zero length file, create it if it does not exist)
'w+' (read and write, file pointer at the beginning, zero length file, create it if it does not exist)
'a' (write only, file pointer at the end, zero length file)
'a+' (read and write, file pointer at the end, zero length file)
'x' (write only, file pointer at the beginning, if exists, return FALSE)
'x+' (read and write, file pointer at the beginning, if exists, return FALSE)
Du kan indsætte alle mulige slags ting i en tekstfil. På en senere side vil jeg oprette en XML fil, vi vil både skrive den og læse fra den. Men vi vil kun bruge dette eksempel for at skrive den. PHP har et modul for at håndtere XML, det vil vi bruge for at læse indholdet.