Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2003-11-19
1
Medium Priority
?
272 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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

718 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