And what about the third option using single quotes on the
outside i.e.  

print  '<INPUT TYPE="TEXT" VALUE="'. $hash["var2"] .'"......

or even better

print '
   <INPUT TYPE="TEXT"
         VALUE="'.$hash["var2"].'"
          SIZE=
......

This should be better than an outer double quote since it
stops any php parsing, so it's a bit faster and you don't
have to
worry if you have any dollar signs in the HTML. It does mean
that you can't just embed the variables but then that
doesn't work for  array variables anyway yet, so it's no
great loss.

I must say I'm tempted by being able to write 
?>
   <INPUT TYPE="TEXT"
          SIZE=<? if ($length>20){print '40';} else {print
'20';}?>
         VALUE=
etc..

rather than my normal style which would be : 

print '
   <INPUT TYPE="TEXT"
          SIZE=';
if ($length>20)
{
   print '40';
} else {
   print '20';
}
print '
         VALUE=
etc..

I'd be very interested to hear other's views on what they
find easiest.  After all, style is 
mostly about making it easy for other people (especially the
inexperienced) to maintain our code, 
not to suit our ideas of elegance. 

My own gut feeling is that consistency is probably the most
important thing, i.e. pick any of the 
styles and then stick to it.  

What do you think?

George Whiffen


Chris Lee wrote:
> 
> im here to start a flamewar.
> 
> dont use " then. why not use ' ?
> 
>   echo "
>   <input type=\"text\" name=\"name\" value=\"$name\">
>    "
> 
>   echo "
>   <input type='text' name='name' value='$name'>
>    "
> I like the second. it is proper html check it with w3.org.
> 
> --
> 
>   Chris Lee
>   [EMAIL PROTECTED]
> 
> ""scott [gts]"" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > on pages with mostly HTML code, the second style is much
> > prefereable, but on pages with mostly PHP code, the first
> > style is usually OK.
> >
> > overall, i tend towards the second, becuase it's a pain
> > in the ass to esape all the double-quotes in my HTML,
> > my echo statements usulaly end up looking like thi
> > (which, to me, is terrible form)
> >
> > echo "<INPUT TYPE=\"TEXT"\" VALUE=\"". $hash['var'] ."\"......
> >
> > so i usually use this format, which to my eyes
> > is much prettier :)
> > ?>
> > <INPUT TYPE="TEXT" VALUE="<?= $hash['var'] ?>">
> > <?
> >
> > > -----Original Message-----
> > > From: James Stevens [mailto:[EMAIL PROTECTED]]
> > > Sent: Wednesday, June 20, 2001 12:23 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: [PHP] General Coding Question
> > >
> > >
> > > Does it have any effect on performance in either case if a file is
> > > completely done in PHP(1) or interspersed with PHP(2).
> > >
> > > (1)
> > > <?php
> > > echo "<html>";
> > > ...
> > > ?>
> > >
> > > (2)
> > > <html>
> > > ...
> > > <?php echo $forminput; ?>
> > > ...
> > >
> > > Also, and this is personal preference, which is easier to read/debug?
> > >
> > > James
> > >
> > >
> > > --
> > > 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]
> > >
> >
> > --
> > 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]
> >
> 
> --
> 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]

-- 
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]

Reply via email to