I want to write the content of a string variable say $data
in to a file named data.xml
the folder location will vary depends upon the content of $appId variable
like i want to write file in
files_dir/$appId/data.xml
moreover if that file already exists than i want to rewrite otherwise i want to create the folder
and then create the file data.xml
Can u suggest some way to do so.
Open file with write mode “w”. will attempt to create file if does not exists otherwise truncate the file to zero length.
You could check if the directory exists
Give the full path of directory and files.