Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Throwing the content of a file directly to the browser (echo a whole file?)

Posted on 2003-11-19
1
Medium Priority
?
275 Views
Last Modified: 2013-11-18
This should be an easy one:
Which is the most effective way (short code, less server processing) to send a whole file to the web client?
What I want to do is this:
Have 4 files: header.html, body1.html, body2.html,footer.html
What I want is depending on some condition the user gets a page which is header+body1+footer or if not header+body2+footer.
Using include or require in PHP includes a file in the current script, which will force me to have humdreds of "echo"s in each of the 4 files to output the HTML - definitely not praclical.
Probably a way would be to read each line-by-line and echo each read line, but I want to know if there is any intelligent and straightforward solution?
0
Comment
Question by:celeron128
1 Comment
 
LVL 6

Accepted Solution

by:
DoppyNL earned 200 total points
ID: 9777452
you can also include html files....

so you can do this:

---- somefile.html
<html>
<head><title>HEAD!!!</title></head>
<body>
-----


---somepage.php
<?php
include('somefile.html');
print('do some other stuff');
print('</body></html>');
?>
-----


or partial php partial html files is also possible. :)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question