Click here to Skip to main content
15,946,179 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 3 files i want to execute them from one file using file_get_contents but it didn't works

index.php :
$page_content = "";
$page_content.= file_get_contents("header.php");
$page_content.= file_get_contents("main.php");
$page_content.= file_get_contents("footer.php");

echo $page_content;

header.php :
<?php echo "Header file"; ?>

main.php :
<?php echo "Main file to include"; ?>

footer.php :
<?php echo "Footer file"; ?>
Peter_in_2780 14-Jul-13 0:20am    
Why do you have the php bracketing in the header/main/footer. You're just outputting it, so the files should contain HTML,
raouf333 14-Jul-13 8:34am    
I will write my html files to output them using file_get_contents but in this files i have some string to display them from a php file.
For example the text existing in the html files would change the language every time i choose a new language from a menu so i need another files (containing the translated strings) to output these text.
So using file_get_contents i need to display both html and php.

1 solution

Use php include_once[^] function.
Share this answer
raouf333 14-Jul-13 8:37am    
i need using file_get_contents :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900