Hey guys...
I am currently using shell_exec to create/add data to about 5 different files. I'd like to get away from shell_exec and use fopen. I'm trying to be a better programmer so what is the best way to use fopen if I need to add data to 5 different files? Do I just simply open/close handle, open/close handle literally 5 times? Or should I create some kind of function for it?
I don't need to read the file.
If the file exists, write to it, if not, create it. If there's data, write over it. That's why I will be using "w".
$fp = fopen("/usr/local/apache/htdocs/dev01.txt","w") or die ("some message");
Here's what I am doing currently...
(don't worry about what it is that I'm doing, it's a LONG story)
Code:
shell_exec("echo \"$dev01\" > /usr/local/apache/htdocs/$dev01.txt");
shell_exec("echo \"$dev02\" > /usr/local/apache/htdocs/$dev02.txt");
shell_exec("echo \"$dev03\" > /usr/local/apache/htdocs/$dev03.txt");
shell_exec("echo \"$dev04\" > /usr/local/apache/htdocs/$dev04.txt");
shell_exec("echo \"$dev05\" > /usr/local/apache/htdocs/$dev05.txt");
So I basically want to replace the above code with fopen function....