Forum Moderators: coopster

Message Too Old, No Replies

php script generated by php

need help generating a file containing php script from php

         

moj0

6:45 pm on Jun 14, 2005 (gmt 0)

10+ Year Member



Hello-

I am trying generate a new PHP file from an existing page using PHP. Currently I'm using the output buffer to capture content destined for the page, and then am capturing that output and writing to a file.

The problem I am having is that all PHP scripts within the new page content are executed and the results are written to the new file, when I would like the PHP code itself to be written to the new file, unprocessed.

So now I am trying to just store the new page as a string and bypass the use of the output buffer, but do not know how to store php code within a string without having it execute.

For example, I'd like to write this string exactly as it is to a new file:
"
<html>
<body>
<? echo "from php";?>
</body>
</html>
"

But I'm getting this as the result:
"
<html>
<body>
from php
</body>
</html>
"

Hope that makes sense -- any help would be much appreciated.

-brian

StupidScript

7:45 pm on Jun 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe this will help get you on your way:

<?

echo <<<PAGE 

<html> 

<body> 

<? echo "from php";?> 

</body> 

</html> 

PAGE;

?>

mcibor

9:48 pm on Jun 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The StupidScript notation is the best one, but you may also consider using single quotes:
<?
$str = '<html>
<body>
<? $v = "from php";
echo $v;?>
</body>
</html> ';

fopen...