the_oliver Posted June 22, 2009 Share Posted June 22, 2009 Hi, I have a script that when called will pull in content from another page using the following: $page_content = str_replace("[[body]]",file_get_contents("pages/".$view.".".$stype),$page_content); echo $page_content; However if i have php code in the included file, its not exicuted. Can any one tell me why that would be please? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/163280-reading-in-php-from-another-file/ Share on other sites More sharing options...
Xyphon Posted June 22, 2009 Share Posted June 22, 2009 Why pull in content from another page like that? Why not just use an include? include('file.php'); Quote Link to comment https://forums.phpfreaks.com/topic/163280-reading-in-php-from-another-file/#findComment-861452 Share on other sites More sharing options...
the_oliver Posted June 22, 2009 Author Share Posted June 22, 2009 The majority of it is HTML.... I tried using include, but for some resion any pages with a ';' in them just print '1' instead of my content. Quote Link to comment https://forums.phpfreaks.com/topic/163280-reading-in-php-from-another-file/#findComment-861462 Share on other sites More sharing options...
ldougherty Posted June 22, 2009 Share Posted June 22, 2009 I agree but assuming there is a reason for your methodology when you view source on the page what does it look like? Quote Link to comment https://forums.phpfreaks.com/topic/163280-reading-in-php-from-another-file/#findComment-861463 Share on other sites More sharing options...
the_oliver Posted June 22, 2009 Author Share Posted June 22, 2009 It seems to be placing the contents of the included file, about the rest of the output... I have a template file and my snipit of php above should search through it and replace '[[body]]' with the contents of the included file. If the file does not contain a ';' its fine! If it does, the the included file appars at the top of the template, before the <HTML> tag. Quote Link to comment https://forums.phpfreaks.com/topic/163280-reading-in-php-from-another-file/#findComment-861471 Share on other sites More sharing options...
Xyphon Posted June 22, 2009 Share Posted June 22, 2009 If it's the ";" and you are trying to echo it, why not use addslashes? Quote Link to comment https://forums.phpfreaks.com/topic/163280-reading-in-php-from-another-file/#findComment-861549 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.