Forum Moderators: coopster

Message Too Old, No Replies

Generate PHP page from PHP

Help on saving php files, generated in php

         

gcarn

3:58 pm on Oct 13, 2009 (gmt 0)

10+ Year Member



Im generating pages out of a database structure, that need to be php pages.

I was hoping that i could simply 'echo' out the php code info my file variable and save it, but its not quite comming out at expected.


ob_start();
echo "TEST <? $siteHeadersFooters->displayTop($headersArray,$hideLangSwitch=true); ?>";
$page = ob_get_clean();
$fullPath='/home/www/docs/test.php';
$fh = fopen($fullPath, 'w') or die("can't open file");
fwrite($fh, $page );
fclose($fh);

Results as the following in the php file:


TEST <? (Array,=true); ?>

I can understand what is happening, I just cant figure out how to make it pass that php code as PHP.

Any help would be greatly appreciated

TheMadScientist

6:31 pm on Oct 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



echo 'TEST <? $siteHeadersFooters->displayTop($headersArray,$hideLangSwitch=true); ?>';

I think, if I'm understanding the question, single quotes are the answer you are looking for... Within double quotes variables are expanded, but they are not within single quotes.

gcarn

7:15 pm on Oct 13, 2009 (gmt 0)

10+ Year Member



Thanks!
Ive always broken out of my quotes to put in variables, I never realized a difference between ' and "