Page 1 of 1

create a file in php with php code into it

Posted: Mon Oct 24, 2005 5:12 pm
by yargon
Hi everybody,

I need to create a temporary file in which I could write some php code from one of my scripts, can anybody help me?

Thanks in advance

Posted: Mon Oct 24, 2005 5:39 pm
by RobertGonzalez
Look up the following functions in the PHP manual and see if you can't follow some of the examples. There a lot of good examples that can be used to develop your own file system application.

tmpfile
fopen
fgets
fputs (or fwrite)
file
fclose

Basically you want to create a file somewhere on the server and open it, write to it the information that you want then close it. I believe the above functions will get you started in the rigth direction.

Posted: Tue Oct 25, 2005 12:13 am
by Jenk
and the use of eval()

But, do be VERY, VERY careful when using eval().

Posted: Tue Oct 25, 2005 7:23 am
by yargon
thank you very much the function that I didn't know about was eval() :)