473,807 Members | 2,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

echo or not to echo?

I have a couple pages that have tables, whats best use echo to produce the
full table with the variables or is it best to just make the table in plain
html and use <?php echo ('$va'l); ?> when i need to see some value.

Example i have tables like this
echo '<div align="',$align ,'"><table border="0" cellpadding="2"
cellspacing="0" width="',$large ur,'">';
echo '<tr><td bgcolor="',$tit re_bgcolor,'">< font face="',$titre_ face,'"
size="',$titre_ size,'" color="',$titre _color,'">&nbsp ;Messages
</font></td>';
echo '<td height="24" bgcolor="',$tit re_bgcolor,'">< font
face="',$titre_ face,'" size="',$titre_ size,'"
color="',$titre _color,'">&nbsp ;Author :</font></td>';
echo '<td bgcolor="',$tit re_bgcolor,'">< font face="',$titre_ face,'"
size="',$titre_ size,'" color="',$titre _color,'">Posts :</font></td>';
echo '<td bgcolor="',$tit re_bgcolor,'" width="140"><fo nt
face="',$titre_ face,'" size="',$titre_ size,'" color="',$titre _color,'">Last
post :</font></td></tr>';

but sometimes i just leave the php like this ?> my table here and i use
<?php echo ('$val'); ?> when i need it.

Both seem to be prety much the same thing to me, i just dont want to waste
processing power with such things even if in both cases it doesnt take that
much time to load the page.
Jul 17 '05 #1
6 2392
Marco wrote:
I have a couple pages that have tables, whats best use echo to produce the
full table with the variables or is it best to just make the table in plain
html and use <?php echo ('$va'l); ?> when i need to see some value.
Parse Error?
<?php echo ('$va'l); ?>

or do you mean
<?php echo ('$val'); ?>
to print 4 characters: $, v, a, l

or do you mean
<?php echo ($val); ?>
to print /whatever/ the variable $val contains? :)
Example i have tables like this
echo '<div align="',$align ,'"><table border="0" cellpadding="2"
cellspacing="0" width="',$large ur,'">';
I do a lot of this ...

but sometimes i just leave the php like this ?> my table here and i use
<?php echo ('$val'); ?> when i need it.
almost never of this ...

Both seem to be prety much the same thing to me, i just dont want to waste
processing power with such things even if in both cases it doesnt take that
much time to load the page.


and I also do a lot of

echo <<<HTML
<div align="$align"> <table border="0" cellpadding="2" cellspacing="0"
width="$largeur ">
HTML;

I would worry more about the code structure and readability than
processing power.

When it doesn't matter, eg:

echo 'your name is ' . $name; // or
echo 'your name is ', $name; // or
echo "your name is $name";

I will test them (a few thousand times) and use the fastest -- as it
happens, the fastest is also the version I like better :)
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2
On Thu, 26 Feb 2004 23:50:00 +0100, "Marco" <mpgtlatbluewin dotch> wrote:
I have a couple pages that have tables, whats best use echo to produce the
full table with the variables or is it best to just make the table in plain
html and use <?php echo ('$va'l); ?> when i need to see some value.

Example i have tables like this
echo '<div align="',$align ,'"><table border="0" cellpadding="2"
cellspacing="0 " width="',$large ur,'">';
echo '<tr><td bgcolor="',$tit re_bgcolor,'">< font face="',$titre_ face,'"
size="',$titre _size,'" color="',$titre _color,'">&nbsp ;Messages
</font></td>';
echo '<td height="24" bgcolor="',$tit re_bgcolor,'">< font
face="',$titre _face,'" size="',$titre_ size,'"
color="',$titr e_color,'">&nbs p;Author :</font></td>';
echo '<td bgcolor="',$tit re_bgcolor,'">< font face="',$titre_ face,'"
size="',$titre _size,'" color="',$titre _color,'">Posts :</font></td>';
echo '<td bgcolor="',$tit re_bgcolor,'" width="140"><fo nt
face="',$titre _face,'" size="',$titre_ size,'" color="',$titre _color,'">Last
post :</font></td></tr>';


Not quite what you were asking, but you'd improve it enormously by doing
something like:

<table class=messages>
<tr><th>Message s</th><th>Author</th><th>Posts</th><th>Last
post</th></tr>

And have a separate CSS file, something like:

..messages th { font-family: Helvetia, Arial; color: black;
background-color: red; padding: 0.5em; }

Much easier to understand, much easier to maintain, more accessible
(because readers with special requirements can substitute their own
stylesheet) and faster to download.

And drop the width attributes on the table altogether; the reader's
browser most probably knows better how to arrange the stuff in his
window than you do.

HTH

--
Stephen Poley
Jul 17 '05 #3
Indeed CSS opens a few more doors, i heard about it here and there but never
realy tryed to know what it realy was.
All my site needs to have 3 differents layouts basicly only the colors will
change from one page to another and with CSS its alot easier and faster to
inplement.
Thanks for your advice, i'll google a "little" to know more about CSS has i
know prety much nothing about it.
"Stephen Poley" <sb************ ******@xs4all.n l> wrote in message
news:hc******** *************** *********@4ax.c om...
On Thu, 26 Feb 2004 23:50:00 +0100, "Marco" <mpgtlatbluewin dotch> wrote:
I have a couple pages that have tables, whats best use echo to produce thefull table with the variables or is it best to just make the table in plainhtml and use <?php echo ('$va'l); ?> when i need to see some value.

Example i have tables like this
echo '<div align="',$align ,'"><table border="0" cellpadding="2"
cellspacing="0 " width="',$large ur,'">';
echo '<tr><td bgcolor="',$tit re_bgcolor,'">< font face="',$titre_ face,'"
size="',$titre _size,'" color="',$titre _color,'">&nbsp ;Messages
</font></td>';
echo '<td height="24" bgcolor="',$tit re_bgcolor,'">< font
face="',$titre _face,'" size="',$titre_ size,'"
color="',$titr e_color,'">&nbs p;Author :</font></td>';
echo '<td bgcolor="',$tit re_bgcolor,'">< font face="',$titre_ face,'"
size="',$titre _size,'" color="',$titre _color,'">Posts :</font></td>';
echo '<td bgcolor="',$tit re_bgcolor,'" width="140"><fo nt
face="',$titre _face,'" size="',$titre_ size,'" color="',$titre _color,'">Lastpost :</font></td></tr>';


Not quite what you were asking, but you'd improve it enormously by doing
something like:

<table class=messages>
<tr><th>Message s</th><th>Author</th><th>Posts</th><th>Last
post</th></tr>

And have a separate CSS file, something like:

.messages th { font-family: Helvetia, Arial; color: black;
background-color: red; padding: 0.5em; }

Much easier to understand, much easier to maintain, more accessible
(because readers with special requirements can substitute their own
stylesheet) and faster to download.

And drop the width attributes on the table altogether; the reader's
browser most probably knows better how to arrange the stuff in his
window than you do.

HTH

--
Stephen Poley

Jul 17 '05 #4
I meant <?php echo ($val); ?>, it was easier to me to understand at the
start cause i could draw the tables with front page ;) and then just use
<?php echo ($val); ?> when i need some variable.

Didnt know about this possibility
echo <<<HTML
<div align="$align"> <table border="0" cellpadding="2" cellspacing="0"
width="$largeur ">
HTML;
Thanks for sharing your point of view ;)

"Pedro Graca" <he****@hotpop. com> wrote in message
news:c1******** *****@ID-203069.news.uni-berlin.de... Marco wrote:
I have a couple pages that have tables, whats best use echo to produce the full table with the variables or is it best to just make the table in plain html and use <?php echo ('$va'l); ?> when i need to see some value.


Parse Error?
<?php echo ('$va'l); ?>

or do you mean
<?php echo ('$val'); ?>
to print 4 characters: $, v, a, l

or do you mean
<?php echo ($val); ?>
to print /whatever/ the variable $val contains? :)
Example i have tables like this
echo '<div align="',$align ,'"><table border="0" cellpadding="2"
cellspacing="0" width="',$large ur,'">';


I do a lot of this ...

but sometimes i just leave the php like this ?> my table here and i use
<?php echo ('$val'); ?> when i need it.


almost never of this ...

Both seem to be prety much the same thing to me, i just dont want to waste processing power with such things even if in both cases it doesnt take that much time to load the page.


and I also do a lot of

echo <<<HTML
<div align="$align"> <table border="0" cellpadding="2" cellspacing="0"
width="$largeur ">
HTML;

I would worry more about the code structure and readability than
processing power.

When it doesn't matter, eg:

echo 'your name is ' . $name; // or
echo 'your name is ', $name; // or
echo "your name is $name";

I will test them (a few thousand times) and use the fastest -- as it
happens, the fastest is also the version I like better :)
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--

Jul 17 '05 #5
Marco top-posted (corrected):
echo <<<HTML
<div align="$align"> <table border="0" cellpadding="2" cellspacing="0"
width="$largeur ">
HTML;
Didnt know about this possibility


It's called heredoc syntax. Read all about it
http://www.php.net/manual/en/language.types.string.php
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #6
"Marco" <mpgtlatbluewin dotch> wrote in message news:<40******* *@news.bluewin. ch>...
I have a couple pages that have tables, whats best use echo to produce the
full table with the variables or is it best to just make the table in plain
html and use <?php echo ('$va'l); ?> when i need to see some value.

Example i have tables like this
echo '<div align="',$align ,'"><table border="0" cellpadding="2"
cellspacing="0" width="',$large ur,'">';
echo '<tr><td bgcolor="',$tit re_bgcolor,'">< font face="',$titre_ face,'"
size="',$titre_ size,'" color="',$titre _color,'">&nbsp ;Messages
</font></td>';
echo '<td height="24" bgcolor="',$tit re_bgcolor,'">< font
face="',$titre_ face,'" size="',$titre_ size,'"
color="',$titre _color,'">&nbsp ;Author :</font></td>';
echo '<td bgcolor="',$tit re_bgcolor,'">< font face="',$titre_ face,'"
size="',$titre_ size,'" color="',$titre _color,'">Posts :</font></td>';
echo '<td bgcolor="',$tit re_bgcolor,'" width="140"><fo nt
face="',$titre_ face,'" size="',$titre_ size,'" color="',$titre _color,'">Last
post :</font></td></tr>';

but sometimes i just leave the php like this ?> my table here and i use
<?php echo ('$val'); ?> when i need it.

Both seem to be prety much the same thing to me, i just dont want to waste
processing power with such things even if in both cases it doesnt take that
much time to load the page.

I used to avoid echo and completely prefer short-tags like:

<table>
<tr>
<td><?=$foo11?> </td><td><?=$foo1 2?></td><td><?=$foo1 3?></td>
</tr>
<tr>
<td><?=$foo21?> </td><td><?=$foo2 2?></td><td><?=$foo2 3?></td>
</tr>
<tr>
<td><?=$foo31?> </td><td><?=$foo3 2?></td><td><?=$foo3 3?></td>
</tr>
</table>

As you see, it is DW friendly. You can easily add "colours" by
opening it in DW. Can add styles, etc too quickly. If you use echo, DW
will show entire code as a PHP and that is hard to touch to add
"colours".

--
"Success is not what you achieve, but it is what you die for"
If you live in USA, please support John Edwards.
Email: rrjanbiah-at-Y!com
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2179
by: lawrence | last post by:
Right now, over at www.monkeyclaus.org, the following script is getting to the 9th run through and dying after the line: echo "..."; You'll admit that is a strange place to die. I've hit refresh several times and it keeps happening. When I view page source, the last thing that shows up is the "...". The date doesn't print, nor does the closing the div tag.
3
2689
by: Michael Flanagan | last post by:
Of course "echo" is working, but I've got a case where php doesn't seem to be sending out the result of an "echo." I'm probably doing something wrong, but I can't see it. I've got the following code on IIS 5.0, Win 2000, PHP 4.3.3, in file LH_Svc.php: <?php $resp = "<response>\r\n"; $respLen = strlen ($resp);
9
3423
by: Domestos | last post by:
Here an unusual one... Say i am writing a few lines of code in php script as so... <?php echo '<table>'; echo '<tr>'; echo '<td> blah blah </td>'; echo '</tr>'; echo '</table>';
9
2060
by: windandwaves | last post by:
Hi Folk My question is: echo all the time vs echo at the end - what is faster Let me explain I used to write pages like this: echo "<head> ";
25
3144
by: Jon Slaughter | last post by:
I have some code that loads up some php/html files and does a few things to them and ultimately returns an html file with some php code in it. I then pass that file onto the user by using echo. Of course then the file doesn't get seen by the user. Is there any command that essentially executes the code and then echo's it? something that will take a string like '<body>blah<?php echo 'Hello'; ?></body>' and actually interpret the php
4
2015
by: rawky1976 | last post by:
Hi, I have a hyperlink which goes to the page below and passes the PK_ID from a query into 'userid'. From this we query the DB and then echo a table with a form; only the textboxes are already populated with the data from the query (in theory)!!! But I get a blank page! I have error reporting on php and mysql but nothing is displayed? <?php echo "<form method=\"post\" action=\"\" style=\"padding-left: 10px\">"; ...
1
2541
by: sheel331 | last post by:
Hello, I am new to coding in PHP, and had a question about a simple thing: I am trying to echo out the elements of an array for a sidenav in one of my HTML pages, and I can't seem to figure out the syntax for appending the element of the array into the path to the file. Here is the code I have: <?php include 'c:\inetpub\webroot\sheel\template\navbar.html';
11
1863
by: Twayne | last post by:
Hi, Irrelevant question time, probably: Is there any advantage/reason to use one format over the other for the following two types of echo statements? 1. echo "error is " . $error; 2. echo "error is $error";
32
2659
by: Request-1 | last post by:
hi folks, html coder here, new and terrified * of php!! aaaaaa! i'm trying to bury a JS script to rotate a photo, in a page i converted from html to php. the conversion went well, it was to use a php session cookie to stop the repeating of an embedded video file on a per session basis; i amended the php code to display a still pic if the session cookie value
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9599
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10624
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5684
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.