You'll have to quote the $ like $string="blablabla \$myvariable blablabla\n"; or you put your string in ' instead of " then you only have to quote the ' if you want to use it in your string. For more information look http://www.php.net/manual/en/language.types.string.php#language.types.string .syntax.single
Greetings Kristin Schesonka "Steve Jackson" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] > I don't know if this is possible but... > > I want to generate a PHP file on the fly. I am trying to use fputs but I > have a problem in that it doesn't print a variable name in the string. > Here is my code: > > Formid is being passed into the string great which is what I want but > how do I get the string to write the variable names in this code? Are > there any rules I need to follow to get the whole file to print out? If > so what? And what should I be looking for in the manual? Fputs isn't > helping much. > > function generate_page($formid, $pagename) > { > // Give the function the string to be generated including formid passed > from > // previous form > $string = "<?php $SECTION_NAME = \"goldfish_cms.php\";\n > //////////////////////////////////////////////////////////////////////// > //////////\n > // Written by Steve Jackson. Copyright and all rights reserved Webpage > 2003.//////\n > /////////////////functions here all included in > output_fns.php////////////////////\n > //////////////////////////////////////////////////////////////////////// > //////////\n > // include the files from output fns to get functions which design the > page\n > include ('output_fns.php');\n > db_connect();\n > $query = \"select * from content where PageID='$formid'\";\n > $result = mysql_query($query) or die(\"Error: Query failure > with<BR>$query<BR>\".mysql_error());\n > while ($array = mysql_fetch_array($result))\n > {\n > $HeadTitle = \"{$array["HeadTitle"]}\"; \n > $PageTitle = \"{$array["Title"]}\"; \n > $BodyText = \"{$array["BodyText"]}\";\n > $Picture1 = \"{$array["PictureOne"]}\";\n > $Picture2 = \"{$array["PictureTwo"]}\";\n > $CatID = \"{$array["CatID"]}\";\n > }\n > // carry the variable head title in the page and do the page header\n > do_html_header($HeadTitle);\n > // carry variables into do_html_index() function in output_fns.\n > // Page title = The headline of the page\n > // Body text = The text body, can include html commands.\n > // Picture 1 = picture or graphic that appears above the title if > required.\n > // Picture 2 = Picture that appears right hand side on the basic > output_fns\n > // CatID = Category which is used for determining which links appear > on each page\n > // Section name = Allows you to specify extra functions to > output_fns.php to be unique to the page (requires hard coding)\n > do_html_index($PageTitle, $BodyText, $Picture1, $Picture2, $CatID, > $SECTION_NAME);\n > // put the page footer in position\n > do_html_footer();\n > ?>\n"; > $filename = 'test.txt'; > $fp = fopen($filename, "a"); > $write = fputs($fp, $string); > fclose($fp); > } > generate_page($formid, $pagename); > > Steve Jackson > Web Development and Marketing Manager > Viola Systems Ltd. > http://www.violasystems.com > [EMAIL PROTECTED] > Mobile +358 50 343 5159 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php