> That's pretty ugly.
>
> echo "<input type='text' name='hello' size='20' value='$value'>";
that isn't html anymore, though.
even though IE and NS may be forgiving, <input type='text' isn't valid.
" it is.
> That's a bit better.
> This is even better still:
>
> echo "<INPUT TYPE='TEXT' NAME='hello' SIZE='20' VALUE='$value'>";
>
> Now, I can see the PHP variable used in there a lot easier than I
> could before. Syntax highlighting would bring it up more, too.
>
>> speaking as an html author, and a lover of php, _please_:
>>
>> <input type="text" name="hello" size="20" value="<?=$value?>">
>>
>> it makes the code useable.
>
> Actually, it makes it less useable for me.
how?
and what about your html production people, who needs to make changes to it?
>> : _never_ and I do mean that _never_ use echo for printing html.
>>
>> it makes your apps impossible to change, and in a production
>> environment, that's not ok.
>
> What if, halfway through a page, I figure out that I need to do a
> redirect or set a cookie?
I suggest you design your applications in such a way that you separate logic
from markup, and preferably assemble your applications out of separate
components that perform "categories" of logical operations. Using markup
that is not contain echos does not preclude good application design.
If you're building pages where database connections on the same page as your
markup, I see why you would say that. As you do larger applications, you'll
find that practice does not scale well:
Have a look at binarycloud.com. binarycloud provides a framework for
building large scale, robust applications that effectively separate markup
from logic. (and it makes coffee!)
> I assemble *all* the page content into a single string variable,
> and echo it out as the last thing the script does. This way I'm
> free to play with HTTP headers right up to that time.
agh!
well, ok - but I suggest that you use functions instead, and call your html
printing functions at the end of your script. or better, build simple
components, and glue them together to make an application that consists of
files that do logical operations, and files that contain markup.
Dumping all that crap into a variable and printing one massive goo-ball
isn't the route to incredible webserver performance, either.
Try stress testing your installations, you'll find apache suddenly needs a
_hideous_ amount of memory.
> However, each to their own - your way works for you and your team,
> mine works for me and mine :)
And as long as you aren't publishing code, do whatever you want.
But as soon as others would like to use it, those practices become a
consideration. I had to clean all kinds of bad habits out of my sytuff
before releasing binarycloud :)
But I certainly can't integrate code into a production process that looks
like this:
echo "<html>";
echo "<head>";
echo "<title>$title</title>";
echo "<link rel='stylesheet' type='text/css'
href='resources/css/$css.css'>";
echo "<script src='/resources/js/base_lib.js'
language='javascript'></script>";
echo "</head>";
echo "<body bgcolor='#EEEEEE' text='#000000' link='#003366' alink='#CCCCCC'
vlink='#003366' topmargin='0' leftmargin='0' marginwidth='0'
marginheight='0'>";
echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'
bgcolor="#000000">";
echo "<tr>";
echo "<td valign='top'><img src='resources/images/binarycloud/tmpl/fire.jpg'
alt='' width='466' height='161' border='0'></td>";
echo "</tr>";
echo "</table>";
it introduces a whole world of unnecessary complexity.
to prove my point:
get one of your friends that knows html but not PHP to look at the above,
then this:
<html>
<head>
<title><?=$title?></title>
<link rel="stylesheet" type="text/css" href="resources/css/<?=$css?>.css">
<script src="/resources/js/base_lib.js" language="javascript"></script>
</head>
<body bgcolor="#EEEEEE" text="#000000" link="#003366" alink="#CCCCCC"
vlink="#003366" topmargin="0" leftmargin="0" marginwidth="0"
marginheight="0">
<table border="0" cellpadding="0" cellspacing="0" width="100%"
bgcolor="#000000">
<tr>
<td valign="top"><img src="resources/images/binarycloud/tmpl/fire.jpg"
alt="" width="466" height="161" border="0"></td>
</tr>
</table>
and see what they have to say.
_alex
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]