Re: Create .php file with php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Jun 25, 2007, at 9:08 PM, jekillen wrote:


On Jun 25, 2007, at 5:13 PM, Marius Toma wrote:

I can not create .php files from PHP. I can save them as *.php5, *.php3, asp, *.txt , etc... but not as .php. I tried both touch and fopen but
none of them worked.

I'm running PHP 5.1.6 on Apache 2, safe_mode is off

Is this a security measure somewhere? How can I bypass it?

Thank you,
Marius

I had trouble with this also running php 5.1.2 and now 5.2.1. But I got the hang of it to the point that I have mostly abandoned xml and flat files for temporary files and quick and dirty data bases that can just be included for their content. I do not remember what I did that got it going but it is definitely possible, almost spooky. You certainly do not want any user supplied content written to a php file as variable values or anything without being completely sanitized. I also had trouble opening and modifying html files but got the hang of that too. I am running Apache 1.3.x on FreeBSD 6.0, 6.2, Mac OSX, and Yellow Dog Linux.
Keep trying...I had to.
JK
I just do $fp = fopen('so_and_so.php', 'w+'); // the 'w+' is necessary for creating files that do not exist and writing to them, just 'w' requires the file to exist already.
fwrite($fp, "<?php\n(code)\n?>");
fclose($fp);
Also in my code editor, the closing php tag screws up the syntax coloring but does not indicate a coding error, so I do $close_tag = '?'.'>'; and in the fclose($fp, "<?php\n(code)\n$close_tag ); and my editor will keep the syntax coloring. (BBEdit)
JK

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux