michaellunsford Posted January 24, 2007 Share Posted January 24, 2007 I've been using str_replace to include html files with file_get_contents(). Well, now the challenge is to [color=green]include[/color] a PHP file.[code]<?phpecho str_replace($string,"|contact_form|",file_get_contents("contact_form.html"));?>[/code]if I use file_get_contents(), it just displays the raw PHP script. If I eval() it, I get errors (unexpected '$' on line 1 -- but there is no $ on line 1?) Quote Link to comment Share on other sites More sharing options...
Carterhost Posted January 24, 2007 Share Posted January 24, 2007 You could use include?[code] <?phpinclude ("footer.php"); ?>[/code] Quote Link to comment Share on other sites More sharing options...
michaellunsford Posted January 24, 2007 Author Share Posted January 24, 2007 can't use include inside str_replace. "include" is treated as a variable instead of a command. Quote Link to comment Share on other sites More sharing options...
Carterhost Posted January 24, 2007 Share Posted January 24, 2007 Eek, Should have engaged brain first!Apologies. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 24, 2007 Share Posted January 24, 2007 Can you post the content of the file you're trying to include? You'll need to use eval() on it, but since that's putting out an error, let's see the code. Quote Link to comment Share on other sites More sharing options...
michaellunsford Posted January 24, 2007 Author Share Posted January 24, 2007 Finally managed to figure it out.The destination PHP file was including another file that generated a cookie. Seems that eval() doesn't know how to say "headers already sent," so I guess it gave me that weird "unexpected '$' on line 1" error ??? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.