Do people generally try and output nicely formatted html from their
scripts?
I have been trying to, with variable indenting for tables etc. It
makes it easier to see the html and perhaps debug it, but it can make
ugly looking scripts.
What's the general consensus?
Craig 12 2089
I do for the most part, but I have never had an ugly script becouse of it.
I do not indent my tables too far in, some times I will restart the nesting
at colom 0 for a table.
--
Mike Bradley http://www.gzentools.com -- free online php tools
"Craig Thomson" <cr***@spam.free> wrote in message
news:76********************************@4ax.com... Do people generally try and output nicely formatted html from their scripts?
I have been trying to, with variable indenting for tables etc. It makes it easier to see the html and perhaps debug it, but it can make ugly looking scripts.
What's the general consensus?
Craig
sorry, I hit send too fast, here is the rest of my post.
sometimes my tables outout like this:
<table>
<tr>
<td>
<table>
<tr>
<td>stuff</td>
</tr>
</table>
<td>
</tr>
</table>
--
Mike Bradley http://www.gzentools.com -- free online php tools
"Craig Thomson" <cr***@spam.free> wrote in message
news:76********************************@4ax.com... Do people generally try and output nicely formatted html from their scripts?
I have been trying to, with variable indenting for tables etc. It makes it easier to see the html and perhaps debug it, but it can make ugly looking scripts.
What's the general consensus?
Craig
Craig Thomson wrote: Do people generally try and output nicely formatted html from their scripts?
I have been trying to, with variable indenting for tables etc. It makes it easier to see the html and perhaps debug it, but it can make ugly looking scripts.
What's the general consensus?
I don't :)
I might put a few "\n" here and there (usually after </tr> or <br/>) but
no indenting for the next line. If I want to look at the HTML produced I
tidy it first with
HTML Tidy ( @ http://www.w3.org/People/Raggett/tidy/ )
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
On Mon, 16 Feb 2004 05:47:05 GMT, Craig Thomson <cr***@spam.free>
wrote: Do people generally try and output nicely formatted html from their scripts?
I have been trying to, with variable indenting for tables etc. It makes it easier to see the html and perhaps debug it, but it can make ugly looking scripts.
What's the general consensus?
Personally, I don't bother.
My PHP code is nicely indented, so debugging is easy from the server
end. Also, I try and output fairly clean HTML (no nested tables, etc)
which makes dubugging from the client end easier.
I don't see the point in cluttering up one's script with \n's and
\t's. The browser doesn't need them and it saves a few bytes bandwidth
;-)
Here's a tip: Single quotes can be used in HTML for attributes, so you
can write:
print("<img src='whatever.png' alt='Whatever'>"); // nice.
as opposed to:
print("<img src=\"whatever.png\" alt=\"Whatever\">"); // ugly.
--
David ( @priz.co.uk )
David Mackenzie writes: Here's a tip: Single quotes can be used in HTML for attributes, so you can write:
print("<img src='whatever.png' alt='Whatever'>"); // nice.
as opposed to:
print("<img src=\"whatever.png\" alt=\"Whatever\">"); // ugly.
Good tip. Here's another one. If ?> is followed immediately by a
newline then the newline will not be output. For example:
<?php echo "cat"; ?>
fish
Will write this:
catfish
If you follow the end-of-line ?> with a space you get this:
cat
fish
--
__o Alex Farran
_`\<,_ Analyst / Programmer
(_)/ (_) www.alexfarran.com
David Mackenzie wrote: Here's a tip: Single quotes can be used in HTML for attributes, so you can write:
print("<img src='whatever.png' alt='Whatever'>"); // nice.
Why use double quotes for PHP at all?
print('<img src="whatever.png" alt="whatever">'); // nicer IMHO
though, if I'm not using the return value of print() i prefer echo()
using the parenthesis-less syntax
echo '<img src="whatever.png" alt="whatever">';
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
On 16 Feb 2004 12:19:23 GMT, Pedro Graca <he****@hotpop.com> wrote: David Mackenzie wrote: Here's a tip: Single quotes can be used in HTML for attributes, so you can write:
print("<img src='whatever.png' alt='Whatever'>"); // nice. Why use double quotes for PHP at all?
I'm used to using double quotes for string literals from other
languages.
print('<img src="whatever.png" alt="whatever">'); // nicer IMHO
They're both preferable to \"whatever\".
--
David ( @priz.co.uk )
Pedro Graca <he****@hotpop.com> wrote in news:c0qcgb$19rnoe$1@ID-
203069.news.uni-berlin.de: David Mackenzie wrote: Here's a tip: Single quotes can be used in HTML for attributes, so you can write:
print("<img src='whatever.png' alt='Whatever'>"); // nice.
Why use double quotes for PHP at all?
print('<img src="whatever.png" alt="whatever">'); // nicer IMHO
But that won't work if you need to interpolate the values of variables into
the generated output.
Eric Bohlman wrote: Pedro Graca <he****@hotpop.com> wrote in news:c0qcgb$19rnoe$1@ID- 203069.news.uni-berlin.de:
David Mackenzie wrote: Here's a tip: Single quotes can be used in HTML for attributes, so you can write:
print("<img src='whatever.png' alt='Whatever'>"); // nice.
Why use double quotes for PHP at all?
print('<img src="whatever.png" alt="whatever">'); // nicer IMHO
But that won't work if you need to interpolate the values of variables into the generated output.
No, it will not. But I prefer to not interpolate
<?php
$oldname = 'Pedro Graca';
echo '<input type="text" name="username" value="', $oldname, '"/>';
?>
is how I do it.
I agree that
<?php
$oldname = 'Pedro Graca';
echo "<input type='name' name='username' value='$oldname'/>";
?>
looks more like HTML than my preferred version, but I find it more
difficult to know what is being printed when interpolation is used.
I don't care for HTML looking scripts :)
One of the first things I do to scripts of other people is
"deinterpolate" it :)
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
I use a composition of objects to produce the output, usually in
combination with files that are included by the objects.
The included files contain most of the lay out and are mostly in html
mode. I usually keep the html in each file properly formatted to make it
readable. I do not bother about the formatting of the final output that
is produced by the objects together. I don't want to becuase that would
make it harder to reuse the objects in whatever combination i like.
If i need to see the overall object composition structure in the output,
i switch on the object's debugging mode so that the start and end of the
output of each composing object is announced in html comments.
Greetings,
Henk Verhoeven.
Craig Thomson wrote: Do people generally try and output nicely formatted html from their scripts?
I have been trying to, with variable indenting for tables etc. It makes it easier to see the html and perhaps debug it, but it can make ugly looking scripts.
What's the general consensus?
Craig
For a while I try to use heredoc, but soon gave up. Nowaday I do a lot of
<?=$var?> and <? foreach():?>...<? endforeach; ?>. Makes fixing HTML layout
issues a little easier than doing echos.
My HTML forms tend to look like this:
<input name="hello" value="<? echo htmlspecialchars($hello); ?>">
<? $checked = araay($which => "checked"); ?>
<input name="which" type="radio" value="a" <?=$checked['a']?>>
<input name="which" type="radio" value="b" <?=$checked['b']?>>
<input name="which" type="radio" value="c" <?=$checked['c']?>>
<? $selected = array($cow => "selected"); ?>
<select name="cow">
<option value="3" <?$selected[3]?>>Mad</option>
<option value="4" <?$selected[4]?>>Dead</option>
<option value="5" <?$selected[5]?>>Tastes like chicken</option>
</select>
Uzytkownik "Craig Thomson" <cr***@spam.free> napisal w wiadomosci
news:76********************************@4ax.com... Do people generally try and output nicely formatted html from their scripts?
I have been trying to, with variable indenting for tables etc. It makes it easier to see the html and perhaps debug it, but it can make ugly looking scripts.
What's the general consensus?
Craig
Eric Bohlman wrote: Pedro Graca <he****@hotpop.com> wrote in news:c0qcgb$19rnoe$1@ID- 203069.news.uni-berlin.de:
David Mackenzie wrote:
Here's a tip: Single quotes can be used in HTML for attributes, so you can write:
print("<img src='whatever.png' alt='Whatever'>"); // nice.
Why use double quotes for PHP at all?
print('<img src="whatever.png" alt="whatever">'); // nicer IMHO
But that won't work if you need to interpolate the values of variables into the generated output.
print "<img src=\"whatever.jpg\" alt=\"$description\">\n";
no problemo.
/m This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: kingofkolt |
last post by:
im trying to let a user download a file from my website, for example a
picture. i dont want the user to have to right-click and do save-as, but
instead i want a window to popup (the window with...
|
by: Paul Lamonby |
last post by:
Hi,
I am generating a HTML formatted email in PHP, but I am getting the
most bizarre error, it will randomly delete characters out of the HTML
code while in transit to the address, therefore...
|
by: Robert V |
last post by:
Hi all, another area I could use some help with is changing submitted data
based on the data conditions ... I will elaborate. I have a form textarea
where a user can type in some text. This text is...
|
by: Nick Forrington |
last post by:
Hi, I'm making a program and have a static Console class that I'm using
to output things, these get sent to the console and also to the graphics
on screen (I'm using SDL). One thing I'm having a...
|
by: Craig Petrie |
last post by:
Hi,
I have a large table in Word 2003 that has formatted text in the cells and
wish to read and convert a cells formatted contents to html output via
vb.net code. The formatting contains the...
|
by: robbiesmith79 |
last post by:
Just so this is out there on the web, I battled the past 24 hours
about this. Background info... I developed a ecommerce website in PHP
4 on a shared linux hosting plan from GoDaddy and had the...
|
by: cybervigilante |
last post by:
I sent HTML formatted email, using PHP, to my Yahoo address from my
server, and it came out fine, styles and all. I sent it to my gmail
address to test it and all I see is the raw html code. But I...
|
by: Peter Nimmo |
last post by:
Hi,
I am writting a windows application that I want to be able to act as if
it where a Console application in certain circumstances, such as error
logging.
Whilst I have nearly got it, it...
|
by: Artie |
last post by:
Hi,
I've searched the web but can't find a solution to an apparently
really simple problem.
My app contains an HTML string and I need to be able to invoke the
Print Dialog to print the HTML...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |