Jump to content
Larry Ullman's Book Forums

Echo Vs Leaving Php And Using Html


Recommended Posts

Hi all,

Please take a quick look at the following code which is a page for calculating the amount of fabric needed for curtains and blinds.

 

<?php
# fabric_enquiry.php
// Di's Soft Furnishings fabric enquiry page
// Starts with the header include
//Header include has links to home, curtains, blinds and other sf
//Page title
$page_title = "Di's Soft Furnishings - fabric quantity enquiry";
include ('includes/header.html');
?>
<h1>How much fabric do you need?</h1>
<?php
include ('includes/fabric_enquiry_curtains_inc.php');
include ('includes/fabric_enquiry_rblinds_inc.php');
?>
<h3>Other links</h3>
<a href="quote.php">Get a quote for curtains and Roman Blinds</a><br />
<a href="measure_curtains.php">How to measure for curtains</a>
<br /><br />
<a href="login.php">Log in to retrieve a quote</a>
<?php
include ('includes/footer.html');
?>

 

As you can see I'm weaving php and html togethor, a bit of one then the other. A general question, but what's the guidance for whether I should use echo and 'stay' in php. For instance I could write the <h1> header as:

echo '<h1>How much fabric do you need?</h1>';

 

Is one way better to use than the other or is it just personal taste? Thinking about it my thought would be that the less times you go in and out of php the less the server needs to work and the faster the page loads. But, of course, I could be talking complete cobblers!

 

Cheers

Paul

Link to comment
Share on other sites

It's entirely a matter of personal taste. There may be performance benefits one way or the other, but I wouldn't use that as a basis for a decision. With the code you've posted, I'd be inclined to do it all in PHP, but if it had a smattering more HTML, I'd probably keep it as is. Whatever you prefer, really.

Link to comment
Share on other sites

  • 3 weeks later...

Hi all,

Please take a quick look at the following code which is a page for calculating the amount of fabric needed for curtains and blinds.

 

<?php
# fabric_enquiry.php
// Di's Soft Furnishings fabric enquiry page
// Starts with the header include
//Header include has links to home, curtains, blinds and other sf
//Page title
$page_title = "Di's Soft Furnishings - fabric quantity enquiry";
include ('includes/header.html');
?>
<h1>How much fabric do you need?</h1>
<?php
include ('includes/fabric_enquiry_curtains_inc.php');
include ('includes/fabric_enquiry_rblinds_inc.php');
?>
<h3>Other links</h3>
<a href="quote.php">Get a quote for curtains and Roman Blinds</a><br />
<a href="measure_curtains.php">How to measure for curtains</a>
<br /><br />
<a href="login.php">Log in to retrieve a quote</a>
<?php
include ('includes/footer.html');
?>

 

As you can see I'm weaving php and html togethor, a bit of one then the other. A general question, but what's the guidance for whether I should use echo and 'stay' in php. For instance I could write the <h1> header as:

echo '<h1>How much fabric do you need?</h1>';

 

Is one way better to use than the other or is it just personal taste? Thinking about it my thought would be that the less times you go in and out of php the less the server needs to work and the faster the page loads. But, of course, I could be talking complete cobblers!

 

Cheers

Paul

 

Hello Paul

 

I use both echo and html and it is a matter ot taste. Echo requires more careful thought about use of punctuation. If I have some html that works on its own, then I insert it a html as opposed to using echo.

Link to comment
Share on other sites

 Share

×
×
  • Create New...