Solved

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

Posted on 2003-11-19
1
241 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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is this error or Notice in php error log? 6 32
datetime in sql 6 31
.htaccess 5 22
selecting both the price and sum(price ) with mysql statement 5 12
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now