create a file in php with php code into it

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yargon
Forum Newbie
Posts: 2
Joined: Mon Oct 24, 2005 4:56 pm

create a file in php with php code into it

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

and the use of eval()

But, do be VERY, VERY careful when using eval().
yargon
Forum Newbie
Posts: 2
Joined: Mon Oct 24, 2005 4:56 pm

Post by yargon »

thank you very much the function that I didn't know about was eval() :)
Post Reply