473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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="',$largeur,'">';
echo '<tr><td bgcolor="',$titre_bgcolor,'"><font face="',$titre_face,'"
size="',$titre_size,'" color="',$titre_color,'">&nbsp;Messages
</font></td>';
echo '<td height="24" bgcolor="',$titre_bgcolor,'"><font
face="',$titre_face,'" size="',$titre_size,'"
color="',$titre_color,'">&nbsp;Author :</font></td>';
echo '<td bgcolor="',$titre_bgcolor,'"><font face="',$titre_face,'"
size="',$titre_size,'" color="',$titre_color,'">Posts :</font></td>';
echo '<td bgcolor="',$titre_bgcolor,'" width="140"><font
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 2371
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="',$largeur,'">';
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" <mpgtlatbluewindotch> 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="',$largeur,'">';
echo '<tr><td bgcolor="',$titre_bgcolor,'"><font face="',$titre_face,'"
size="',$titre_size,'" color="',$titre_color,'">&nbsp;Messages
</font></td>';
echo '<td height="24" bgcolor="',$titre_bgcolor,'"><font
face="',$titre_face,'" size="',$titre_size,'"
color="',$titre_color,'">&nbsp;Author :</font></td>';
echo '<td bgcolor="',$titre_bgcolor,'"><font face="',$titre_face,'"
size="',$titre_size,'" color="',$titre_color,'">Posts :</font></td>';
echo '<td bgcolor="',$titre_bgcolor,'" width="140"><font
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>Messages</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.nl> wrote in message
news:hc********************************@4ax.com...
On Thu, 26 Feb 2004 23:50:00 +0100, "Marco" <mpgtlatbluewindotch> 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="',$largeur,'">';
echo '<tr><td bgcolor="',$titre_bgcolor,'"><font face="',$titre_face,'"
size="',$titre_size,'" color="',$titre_color,'">&nbsp;Messages
</font></td>';
echo '<td height="24" bgcolor="',$titre_bgcolor,'"><font
face="',$titre_face,'" size="',$titre_size,'"
color="',$titre_color,'">&nbsp;Author :</font></td>';
echo '<td bgcolor="',$titre_bgcolor,'"><font face="',$titre_face,'"
size="',$titre_size,'" color="',$titre_color,'">Posts :</font></td>';
echo '<td bgcolor="',$titre_bgcolor,'" width="140"><font
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>Messages</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="',$largeur,'">';


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" <mpgtlatbluewindotch> 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="',$largeur,'">';
echo '<tr><td bgcolor="',$titre_bgcolor,'"><font face="',$titre_face,'"
size="',$titre_size,'" color="',$titre_color,'">&nbsp;Messages
</font></td>';
echo '<td height="24" bgcolor="',$titre_bgcolor,'"><font
face="',$titre_face,'" size="',$titre_size,'"
color="',$titre_color,'">&nbsp;Author :</font></td>';
echo '<td bgcolor="',$titre_bgcolor,'"><font face="',$titre_face,'"
size="',$titre_size,'" color="',$titre_color,'">Posts :</font></td>';
echo '<td bgcolor="',$titre_bgcolor,'" width="140"><font
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><?=$foo12?></td><td><?=$foo13?></td>
</tr>
<tr>
<td><?=$foo21?></td><td><?=$foo22?></td><td><?=$foo23?></td>
</tr>
<tr>
<td><?=$foo31?></td><td><?=$foo32?></td><td><?=$foo33?></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
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...
3
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...
9
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
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
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...
4
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...
1
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...
11
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. ...
32
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...

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.