Solved

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

Posted on 2003-11-19
1
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

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 …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

729 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