Cod-nes Posted December 30, 2008 Share Posted December 30, 2008 How do I write this into a file? <?php$file=fopen("config.php","w");$pass=md5($ap);$info="<?phpfunction showfooter(){$copy=true;$title=\"test\";$aq=\\"http:\/\/test\\";if($copy=true){echo \"Powered by <a href=\\"$aq\\">Something</a> - Something 2009\";}else {echo "something here";if(file_exist(\"footer.php\")){include(\"footer.php\");}}}?>"fwrite($file,$info);$fclose($file);?> (Only a part of the file.)As you can see I need another slash. Two of these: \\. But they cancel themselves out or something that I get Parse error: syntax error, unexpected T_VARIABLE on the line of: $aq=\\"http:\/\/test\\"; Link to comment Share on other sites More sharing options...
jeffman Posted December 30, 2008 Share Posted December 30, 2008 Try using single quotes inside the doubles. Unless you're interpolating variables, single quotes are the norm in PHP anyway. Link to comment Share on other sites More sharing options...
Cod-nes Posted December 30, 2008 Author Share Posted December 30, 2008 Tried that. echo \"Powered by <a href=\"$aq\">Something</a> - Something 2009\"; It appears like this in config.php echo "Powered by <a href="$aq">Something</a> - Something 2009"; Then I get a error that wrong use of echo or something. Link to comment Share on other sites More sharing options...
Synook Posted December 30, 2008 Share Posted December 30, 2008 You should just use HEREDOC - much simpler. http://www.php.net/manual/en/language.type....syntax.heredoc Link to comment Share on other sites More sharing options...
Cod-nes Posted December 30, 2008 Author Share Posted December 30, 2008 It works. Thanks. ^^ The file config.php gets created perfectly but there's this strange problem when I fwrite the infomation to the file. I get "Fatal error: Call to undefined function: ()". Is there a way to stop functions from running when we fwrite them into files? Link to comment Share on other sites More sharing options...
Synook Posted December 31, 2008 Share Posted December 31, 2008 What line does it say the error is on?Also, you have a logic error in this code: if($copy=true) Link to comment Share on other sites More sharing options...
Cod-nes Posted December 31, 2008 Author Share Posted December 31, 2008 I have edited the file. The error is on: Fatal error: Call to undefined function: () in install.php on line 62Install.php PROBLEM SOLVED. Link to comment Share on other sites More sharing options...
Synook Posted December 31, 2008 Share Posted December 31, 2008 Look at line 62. Something seem wrong? $fclose($file); Link to comment Share on other sites More sharing options...
Cod-nes Posted December 31, 2008 Author Share Posted December 31, 2008 Thanks it works! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.