Re[2]: [PHP] Code optimization: single vs. double quotes?

2003-10-28 Thread Tom Rogers
Hi,

Tuesday, October 28, 2003, 9:26:13 AM, you wrote:
CWP Curt Zirzow mailto:[EMAIL PROTECTED]
CWP on Monday, October 27, 2003 3:16 PM said:

 5. no newline after the tr. :)
 
 There are some broswer issues with tr and td's not being on the
 same line.

CWP Ok I resisted sending this earlier but it appears it is now necessary.
CWP ;)

CWP Here is how I WOULD have written that line had it been in my own code.
CWP (Minus some CSS that could be put in.)

CWPecho table\n
CWP. tr\n
CWP.  td class=\row_bright\$somevalue/td\n
CWP. /tr\n
CWP./table\n;

I find the . operator to be very slow with strings :)
(slow being relative of course)
-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Code optimization: single vs. double quotes?

2003-10-27 Thread Chris W. Parker
olinux mailto:[EMAIL PROTECTED]
on Friday, October 24, 2003 9:41 PM said:

 echo td bgcolor=\$bgcolor2\nbsp;/td/tr;
 
 uggh - apparently you've never had to redesign a
 site/application that uses this style. This is one
 table cell, but when you work this style through a big
 app, it's a huge pain (waste of time) to make any
 changes.

Apparently. What do you recommend?



c.

--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Code optimization: single vs. double quotes?

2003-10-27 Thread Jay Blanchard
[snip]

 echo td bgcolor=\$bgcolor2\nbsp;/td/tr;
 
 uggh - redesign 

recommend?
[/snip]

CSS! :)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Code optimization: single vs. double quotes?

2003-10-27 Thread Chris W. Parker
Jay Blanchard mailto:[EMAIL PROTECTED]
on Monday, October 27, 2003 9:31 AM said:

 CSS! :)

Oh that's what he meant? I thought he was talking about the quoting
style used on that line.


Chris.

p.s. The last time I actually used bgcolor was probably almost a year
ago. :)

--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Code optimization: single vs. double quotes?

2003-10-27 Thread Justin French
On Tuesday, October 28, 2003, at 04:29  AM, Chris W. Parker wrote:

olinux mailto:[EMAIL PROTECTED]
on Friday, October 24, 2003 9:41 PM said:
echo td bgcolor=\$bgcolor2\nbsp;/td/tr;
uggh - apparently you've never had to redesign a
site/application that uses this style. This is one
table cell, but when you work this style through a big
app, it's a huge pain (waste of time) to make any
changes.
Apparently. What do you recommend?
You have plenty of options... a  b would be my preference:

a) echo td bgcolor='{$bgcolor2}'nbsp;/td/tr;
b) echo td bgcolor='$bgcolor2'nbsp;/td/tr;
c) echo 'td bgcolor='.$bgcolor2.'nbsp;/td/tr';
d) echo td bgcolor='.$bgcolor2.'nbsp;/td/tr;
Justin French

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Code optimization: single vs. double quotes?

2003-10-27 Thread Chris W. Parker
Justin French mailto:[EMAIL PROTECTED]
on Monday, October 27, 2003 2:12 PM said:

 a) echo td bgcolor='{$bgcolor2}'nbsp;/td/tr;
 b) echo td bgcolor='$bgcolor2'nbsp;/td/tr;
 c) echo 'td bgcolor='.$bgcolor2.'nbsp;/td/tr';
 d) echo td bgcolor='.$bgcolor2.'nbsp;/td/tr;

Exactly what is the problem with:

echo td bgcolor=\$bgcolor2\nbsp;/td/tr;

I don't see the problem.



Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Code optimization: single vs. double quotes?

2003-10-27 Thread Chris Shiflett
--- Justin French [EMAIL PROTECTED] wrote:
 a) echo td bgcolor='{$bgcolor2}'nbsp;/td/tr;

The curly braces are superfluous here, since you are using double quotes. I'm
not sure if you like having them there, but I think that less syntax yields a
simpler and cleaner appearance.

However, I hate single quotes around HTML attributes, so I can't bring myself
to use that format anyway. :-)

Chris

=
My Blog
 http://shiflett.org/
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Code optimization: single vs. double quotes?

2003-10-27 Thread Chris W. Parker
Chris Shiflett mailto:[EMAIL PROTECTED]
on Monday, October 27, 2003 2:30 PM said:

 --- Justin French [EMAIL PROTECTED] wrote:
 a) echo td bgcolor='{$bgcolor2}'nbsp;/td/tr;
 
 The curly braces are superfluous here, since you are using double
 quotes. I'm not sure if you like having them there, but I think that
 less syntax yields a simpler and cleaner appearance.
 
 However, I hate single quotes around HTML attributes, so I can't
 bring myself to use that format anyway. :-)

+1

--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Code optimization: single vs. double quotes?

2003-10-27 Thread Chris Shiflett
--- Chris W. Parker [EMAIL PROTECTED] wrote:
 Exactly what is the problem with:
 
 echo td bgcolor=\$bgcolor2\nbsp;/td/tr;
 
 I don't see the problem.

I agree with you, actually. The only things I don't like are:

1. The use of the bgcolor attribute
2. The name of the variable :-)
3. The fact that your td is not tabbed in
4. The closing tr being on the same line

But, everyone has different tastes. I tend to choose whichever format makes my
HTML look perfect while requiring the least amount of syntax in PHP.

Chris

=
My Blog
 http://shiflett.org/
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Code optimization: single vs. double quotes?

2003-10-27 Thread Curt Zirzow
* Thus wrote Chris Shiflett ([EMAIL PROTECTED]):
 --- Chris W. Parker [EMAIL PROTECTED] wrote:
  Exactly what is the problem with:
  
  echo td bgcolor=\$bgcolor2\nbsp;/td/tr;
  
  I don't see the problem.
 
 I agree with you, actually. The only things I don't like are:
 
 1. The use of the bgcolor attribute
 2. The name of the variable :-)
 3. The fact that your td is not tabbed in
 4. The closing tr being on the same line
 
 But, everyone has different tastes. I tend to choose whichever format makes my
 HTML look perfect while requiring the least amount of syntax in PHP.

5. no newline after the tr. :)

There are some broswer issues with tr and td's not being on the
same line.  But I guess that shouldn't matter much cause tables
shouldn't be used for layout design.


Curt
-- 
My PHP key is worn out

  PHP List stats since 1997: 
http://zirzow.dyndns.org/html/mlists/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Code optimization: single vs. double quotes?

2003-10-27 Thread DvDmanDT
It's said that you shouldn't use tables for layout, but does people
accutually listen to that? And what instead?

-- 
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
##
Please, if you are using windows, you may be infected by Swen. Please go
here to find out more:
http://us.mcafee.com/virusInfo/default.asp?id=helpCenterhcName=swen
http://securityresponse.symantec.com/avcenter/venc/data/[EMAIL PROTECTED]
##
Curt Zirzow [EMAIL PROTECTED] skrev i meddelandet
news:[EMAIL PROTECTED]
 * Thus wrote Chris Shiflett ([EMAIL PROTECTED]):
  --- Chris W. Parker [EMAIL PROTECTED] wrote:
   Exactly what is the problem with:
  
   echo td bgcolor=\$bgcolor2\nbsp;/td/tr;
  
   I don't see the problem.
 
  I agree with you, actually. The only things I don't like are:
 
  1. The use of the bgcolor attribute
  2. The name of the variable :-)
  3. The fact that your td is not tabbed in
  4. The closing tr being on the same line
 
  But, everyone has different tastes. I tend to choose whichever format
makes my
  HTML look perfect while requiring the least amount of syntax in PHP.

 5. no newline after the tr. :)

 There are some broswer issues with tr and td's not being on the
 same line.  But I guess that shouldn't matter much cause tables
 shouldn't be used for layout design.


 Curt
 -- 
 My PHP key is worn out

   PHP List stats since 1997:
 http://zirzow.dyndns.org/html/mlists/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Code optimization: single vs. double quotes?

2003-10-27 Thread Mike Migurski
It's said that you shouldn't use tables for layout, but does people
accutually listen to that? And what instead?

This is veering off-topic, but:
http://css-discuss.incutio.com/?page=CssLayouts

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Code optimization: single vs. double quotes?

2003-10-27 Thread Chris W. Parker
Curt Zirzow mailto:[EMAIL PROTECTED]
on Monday, October 27, 2003 3:16 PM said:

 5. no newline after the tr. :)
 
 There are some broswer issues with tr and td's not being on the
 same line.

Ok I resisted sending this earlier but it appears it is now necessary.
;)

Here is how I WOULD have written that line had it been in my own code.
(Minus some CSS that could be put in.)

echo table\n
. tr\n
.  td class=\row_bright\$somevalue/td\n
. /tr\n
./table\n;

 But I guess that shouldn't matter much cause tables
 shouldn't be used for layout design.

In an effort to avoid confusing people that don't know any better
layout design means everything except forms and data.


Chris.

p.s. And yes Curt you touched on why I put my td/td's all on one
line. Some browsers (I know IE does) like to add whitespace if the td
and /td are not all on the same line.

--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Code optimization: single vs. double quotes?

2003-10-27 Thread Chris Shiflett
--- DvDmanDT [EMAIL PROTECTED] wrote:
 It's said that you shouldn't use tables for layout, but does people
 accutually listen to that? And what instead?

You can use stylesheets.

These work well with PHP. Well, that's my attempt at getting this thread back
on topic. :-)

Chris

=
My Blog
 http://shiflett.org/
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Code optimization: single vs. double quotes?

2003-10-27 Thread Chris Shiflett
--- Chris W. Parker [EMAIL PROTECTED] wrote:
 p.s. And yes Curt you touched on why I put my td/td's all on
 one line. Some browsers (I know IE does) like to add whitespace if
 the td and /td are not all on the same line.

Which is why I didn't complain about that. :-)

You had your closing tr on the same line. That was not related to spacing
concerns, I assume.

Chris

=
My Blog
 http://shiflett.org/
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Code optimization: single vs. double quotes?

2003-10-27 Thread Justin French
On Tuesday, October 28, 2003, at 09:23  AM, Chris W. Parker wrote:

Exactly what is the problem with:

echo td bgcolor=\$bgcolor2\nbsp;/td/tr;
it's purely personal -- i don't enjoy writing, re-writing, debugging or 
modifying code with 100's of escaped double quotes everywhere when they 
really aren't needed.

Justin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Code optimization: single vs. double quotes?

2003-10-27 Thread Justin French
On Tuesday, October 28, 2003, at 09:29  AM, Chris Shiflett wrote:

--- Justin French [EMAIL PROTECTED] wrote:
a) echo td bgcolor='{$bgcolor2}'nbsp;/td/tr;
The curly braces are superfluous here, since you are using double 
quotes. I'm
not sure if you like having them there, but I think that less syntax 
yields a
simpler and cleaner appearance.
Yes, they are superfluous in this example, but not because we're in 
double quotes.  You can ONLY use complex strings inside double quotes, 
AFAIK:

?
$str = blah;
echo {$str}br /;// echos blahbr /
echo '{$str}br /';  // echos {$str}br /
?
As I'm sure you're aware, the use of the {braces} is to allow complex 
combinations of variables, like found in the manual 
http://www.php.net/types.string

In the above example, they are indeed not needed, but I've gotten into 
the habbit of using them on all strings for a few reasons;

- the fact that there can be no confusion (either human or PHP) over 
what I mean
- PHP will be non-greedy when looking for the valid variable name
- since i'm now in the habbit, I never have to debug examples where it 
IS needed :)


However, I hate single quotes around HTML attributes, so I can't bring 
myself
to use that format anyway. :-)
Well, that's where we come down to personal opinion... personally, 
seeing \ 100's of times in a script doesn't turn me on at all :)

Justin French

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Code optimization: single vs. double quotes?

2003-10-24 Thread Nathan Taylor
I am a recent fan of the single-quotes.  I used to use double only but when some gurus 
told me the disadvantages I converted my entire project over to single quotes.  Single 
quotes are ideal because as far coding goes it greatly decreases the time of 
development when you don't have to worry about dropping in the escape character on 
your HTML values, etc.  Granted, single quotes can be a nuisance in some instances 
(like when you need a new line character) but of course there is a way around.  I 
simply define a constant and call that at the end of every line in order to substitute 
for the new line character.

Horizontal Tab - define(T, chr(9));
New Line - define(NL, chr(10));

Cheers,
Nathan
  - Original Message - 
  From: Robert Cummings 
  To: Shawn McKenzie 
  Cc: PHP-General 
  Sent: Thursday, October 23, 2003 10:30 PM
  Subject: Re: [PHP] Code optimization: single vs. double quotes?


  On Thu, 2003-10-23 at 20:43, Shawn McKenzie wrote:
   I came across this post and was hoping to get a gurus opinion on the
   validity.  TIA
   
   -Shawn
   
   I remember reading somewhere re: PHP coding that it is a better coding
   practice to use single quotes as much as possible vs. using double quotes in
   scripts. When using double quotes, you are forcing PHP to look for variables
   within them, even though there may not be any, thus slowing execution
   time...
   
   For example it is better to code:
 Code:
 echo 'td bgcolor='.$bgcolor2.'nbsp;/td/tr';
   
   vs.
 Code:
 echo td bgcolor=\$bgcolor2\nbsp;/td/tr;

  Better is a very subjective question; however, style 1 will run faster
  since it won't look for variable interpolation. Personally I always use
  style 1 unless I specifically need variable interpolation or one of the
  special characters such as a newline. Also when doing HTML the double
  quotes fit nicely in the the single quote paradigm. On the other hand
  when I do SQL queries, I often allow interpolation just because it is
  more readable and because I usually use single quotes to wrap strings in
  my queries.

  HTH,
  Rob.
  -- 
  ..
  | InterJinn Application Framework - http://www.interjinn.com |
  ::
  | An application and templating framework for PHP. Boasting  |
  | a powerful, scalable system for accessing system services  |
  | such as forms, properties, sessions, and caches. InterJinn |
  | also provides an extremely flexible architecture for   |
  | creating re-usable components quickly and easily.  |
  `'

  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Code optimization: single vs. double quotes?

2003-10-24 Thread Justin French
On Friday, October 24, 2003, at 10:43  AM, Shawn McKenzie wrote:

For example it is better to code:
  Code:
  echo 'td bgcolor='.$bgcolor2.'nbsp;/td/tr';
vs.
  Code:
  echo td bgcolor=\$bgcolor2\nbsp;/td/tr;
Better is a very loose term, but I've adopted a coding style which 
uses single quotes on all lines which don't require special characters 
(\n, \t, etc) or variables.

At the same time, I dropped double quotes within my HTML where 
possible, realising that most of my echo's had double quotes, so I was 
escaping a lot of quotes.

I also adapted wrapping all variables in {parenthesis} so that PHP has 
no chance of being confused

On all but the most heavily visited sites, it's my humble opinion that 
you should take the approach of what's fast for you to code, read, 
maintain and re-develop, rather than what might get you a .0001 
% performance gain -- this is most likely due to the nature of the 
sites I develop -- but this seems to be the general consensus I've read 
over many years and from many sources.

No special chars or vars:
echo 'td bgcolor=\'#ff\'nbsp;/td/tr';
For cases with vars and special chars, I think these look terrible:
echo 'td bgcolor='.$bgcolor2.'nbsp;/td/tr';
echo td bgcolor=\$bgcolor2\nbsp;/td/tr;
Whereas this is clear and easy to work with:
echo td bgcolor='{$bgcolor2}'nbsp;/td/tr;
You mileage will vary, but unless you're working on a hugely successful 
site (the kind that needs a dedicated server), take your personal 
preferences, and long-term readability and maintainability into account 
when deciding what suits you.

Justin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Code optimization: single vs. double quotes?

2003-10-24 Thread Richard Baskett
on 10/24/03 0:47, Nathan Taylor at [EMAIL PROTECTED] wrote:

 I am a recent fan of the single-quotes.  I used to use double only but when
 some gurus told me the disadvantages I converted my entire project over to
 single quotes.  Single quotes are ideal because as far coding goes it greatly
 decreases the time of development when you don't have to worry about dropping
 in the escape character on your HTML values, etc.  Granted, single quotes can
 be a nuisance in some instances (like when you need a new line character) but
 of course there is a way around.  I simply define a constant and call that at
 the end of every line in order to substitute for the new line character.
 
 Horizontal Tab - define(T, chr(9));
 New Line - define(NL, chr(10));
 
 Cheers,
 Nathan
 - Original Message -
 From: Robert Cummings
 To: Shawn McKenzie
 Cc: PHP-General 
 Sent: Thursday, October 23, 2003 10:30 PM
 Subject: Re: [PHP] Code optimization: single vs. double quotes?
 
 
 On Thu, 2003-10-23 at 20:43, Shawn McKenzie wrote:
 I came across this post and was hoping to get a gurus opinion on the
 validity.  TIA
 
 -Shawn
 
 I remember reading somewhere re: PHP coding that it is a better coding
 practice to use single quotes as much as possible vs. using double quotes in
 scripts. When using double quotes, you are forcing PHP to look for variables
 within them, even though there may not be any, thus slowing execution
 time...
 
 For example it is better to code:
   Code:
   echo 'td bgcolor='.$bgcolor2.'nbsp;/td/tr';
 
 vs.
   Code:
   echo td bgcolor=\$bgcolor2\nbsp;/td/tr;
 
 Better is a very subjective question; however, style 1 will run faster
 since it won't look for variable interpolation. Personally I always use
 style 1 unless I specifically need variable interpolation or one of the
 special characters such as a newline. Also when doing HTML the double
 quotes fit nicely in the the single quote paradigm. On the other hand
 when I do SQL queries, I often allow interpolation just because it is
 more readable and because I usually use single quotes to wrap strings in
 my queries.

Now what is wrong with doing this?

echo 'td bgcolor=whitenbsp;/td'.\r\n;

That way you can still use your single quotes and still being able to use
the \r\n.. that does work doesn¹t it?  Im pretty sure I have used it
before..

Anyways I guess the point is that you are not forced to use double quotes
for the full echo just so you can use the special newline characters..

Rick

Freedom and immorality can not co-exist because freedom requires personal
responsibility. - Unknown

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Code optimization: single vs. double quotes?

2003-10-24 Thread Joachim Krebs
That style is also the one I use. It works well, it is clean, and it is 
straightforward.

Joachim

Richard Baskett wrote:
on 10/24/03 0:47, Nathan Taylor at [EMAIL PROTECTED] wrote:


I am a recent fan of the single-quotes.  I used to use double only but when
some gurus told me the disadvantages I converted my entire project over to
single quotes.  Single quotes are ideal because as far coding goes it greatly
decreases the time of development when you don't have to worry about dropping
in the escape character on your HTML values, etc.  Granted, single quotes can
be a nuisance in some instances (like when you need a new line character) but
of course there is a way around.  I simply define a constant and call that at
the end of every line in order to substitute for the new line character.
Horizontal Tab - define(T, chr(9));
New Line - define(NL, chr(10));
Cheers,
Nathan
- Original Message -
From: Robert Cummings
To: Shawn McKenzie
Cc: PHP-General 
Sent: Thursday, October 23, 2003 10:30 PM
Subject: Re: [PHP] Code optimization: single vs. double quotes?

On Thu, 2003-10-23 at 20:43, Shawn McKenzie wrote:

I came across this post and was hoping to get a gurus opinion on the
validity.  TIA
-Shawn

I remember reading somewhere re: PHP coding that it is a better coding
practice to use single quotes as much as possible vs. using double quotes in
scripts. When using double quotes, you are forcing PHP to look for variables
within them, even though there may not be any, thus slowing execution
time...
For example it is better to code:
 Code:
 echo 'td bgcolor='.$bgcolor2.'nbsp;/td/tr';
vs.
 Code:
 echo td bgcolor=\$bgcolor2\nbsp;/td/tr;
Better is a very subjective question; however, style 1 will run faster
since it won't look for variable interpolation. Personally I always use
style 1 unless I specifically need variable interpolation or one of the
special characters such as a newline. Also when doing HTML the double
quotes fit nicely in the the single quote paradigm. On the other hand
when I do SQL queries, I often allow interpolation just because it is
more readable and because I usually use single quotes to wrap strings in
my queries.


Now what is wrong with doing this?

echo 'td bgcolor=whitenbsp;/td'.\r\n;

That way you can still use your single quotes and still being able to use
the \r\n.. that does work doesn¹t it?  Im pretty sure I have used it
before..
Anyways I guess the point is that you are not forced to use double quotes
for the full echo just so you can use the special newline characters..
Rick

Freedom and immorality can not co-exist because freedom requires personal
responsibility. - Unknown
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Code optimization: single vs. double quotes?

2003-10-24 Thread olinux

 No special chars or vars:
 echo 'td bgcolor=\'#ff\'nbsp;/td/tr';
 
 For cases with vars and special chars, I think these
 look terrible:
 echo 'td bgcolor='.$bgcolor2.'nbsp;/td/tr';

I'm a fan of this style - works great with syntax
highlighting in homesite.

olinux


 echo td bgcolor=\$bgcolor2\nbsp;/td/tr;
 
 Whereas this is clear and easy to work with:
 echo td bgcolor='{$bgcolor2}'nbsp;/td/tr;


__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Code optimization: single vs. double quotes?

2003-10-24 Thread Robert Cummings
On Fri, 2003-10-24 at 03:57, Justin French wrote:
 On Friday, October 24, 2003, at 10:43  AM, Shawn McKenzie wrote:
 
 [--CLIPPETY CLIP CLIP--]
 
 Whereas this is clear and easy to work with:
 echo td bgcolor='{$bgcolor2}'nbsp;/td/tr;
 

Unless your $bgcolor2 variable has double quotes in it, then the above
is poor HTML style. I don't think omission of double quotes has been
considered valid HTML since version 3 (admittedly though, as long as
they let it render, people will use it :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Code optimization: single vs. double quotes?

2003-10-24 Thread Chris W. Parker
Justin French mailto:[EMAIL PROTECTED]
on Friday, October 24, 2003 12:57 AM said:

 I also adapted wrapping all variables in {parenthesis} so that PHP has
 no chance of being confused

heh... actually those are {curly braces} and these are (parenthesis).

 No special chars or vars:
 echo 'td bgcolor=\'#ff\'nbsp;/td/tr';

Even better (and valid HTML too!):

echo 'td bgcolor=#ffnbsp;/td/tr';


I've always been a big fan of:

 echo td bgcolor=\$bgcolor2\nbsp;/td/tr;

But this has been an interesting topic so I might just start changing my
style.


Chris.

p.s. If you're wondering how heredoc fits into all of this, it's really
slow.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Code optimization: single vs. double quotes?

2003-10-24 Thread Marek Kilimajer
Robert Cummings wrote:
echo td bgcolor='{$bgcolor2}'nbsp;/td/tr;
Unless your $bgcolor2 variable has double quotes in it, then the above
is poor HTML style. I don't think omission of double quotes has been
considered valid HTML since version 3 (admittedly though, as long as
they let it render, people will use it :)
Cheers,
Rob.
Single quotes are valid in html, though not in xhtml.

Marek

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Code optimization: single vs. double quotes?

2003-10-24 Thread Robert Cummings
On Fri, 2003-10-24 at 12:03, Marek Kilimajer wrote:
 Robert Cummings wrote:
 echo td bgcolor='{$bgcolor2}'nbsp;/td/tr;
  
  Unless your $bgcolor2 variable has double quotes in it, then the above
  is poor HTML style. I don't think omission of double quotes has been
  considered valid HTML since version 3 (admittedly though, as long as
  they let it render, people will use it :)
  
  Cheers,
  Rob.
 
 Single quotes are valid in html, though not in xhtml.

Whoops my bad, for some reason I saw those single quotes as string
delimiters, which really makes no sense on my part at all. I'm claiming
the just woke up excuse :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Code optimization: single vs. double quotes?

2003-10-24 Thread olinux
--- Chris W. Parker [EMAIL PROTECTED] wrote:
 
 I've always been a big fan of:
 
  echo td bgcolor=\$bgcolor2\nbsp;/td/tr;
 

uggh - apparently you've never had to redesign a
site/application that uses this style. This is one
table cell, but when you work this style through a big
app, it's a huge pain (waste of time) to make any
changes.

olinux


__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Code optimization: single vs. double quotes?

2003-10-23 Thread Shawn McKenzie
I came across this post and was hoping to get a gurus opinion on the
validity.  TIA

-Shawn

I remember reading somewhere re: PHP coding that it is a better coding
practice to use single quotes as much as possible vs. using double quotes in
scripts. When using double quotes, you are forcing PHP to look for variables
within them, even though there may not be any, thus slowing execution
time...

For example it is better to code:
  Code:
  echo 'td bgcolor='.$bgcolor2.'nbsp;/td/tr';

vs.
  Code:
  echo td bgcolor=\$bgcolor2\nbsp;/td/tr;

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Code optimization: single vs. double quotes?

2003-10-23 Thread Jordan S. Jones
I remember reading something very very similar from one of the main php 
developers.. However, for the life of me, I can't remember where it was 
exactly...

Jordan S. Jones

Shawn McKenzie wrote:

I came across this post and was hoping to get a gurus opinion on the
validity.  TIA
-Shawn

I remember reading somewhere re: PHP coding that it is a better coding
practice to use single quotes as much as possible vs. using double quotes in
scripts. When using double quotes, you are forcing PHP to look for variables
within them, even though there may not be any, thus slowing execution
time...
For example it is better to code:
 Code:
 echo 'td bgcolor='.$bgcolor2.'nbsp;/td/tr';
vs.
 Code:
 echo td bgcolor=\$bgcolor2\nbsp;/td/tr;
 

--
I am nothing but a poor boy. Please Donate..
https://www.paypal.com/xclick/business=list%40racistnames.comitem_name=Jordan+S.+Jonesno_note=1tax=0currency_code=USD
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Code optimization: single vs. double quotes?

2003-10-23 Thread Robert Cummings
On Thu, 2003-10-23 at 20:43, Shawn McKenzie wrote:
 I came across this post and was hoping to get a gurus opinion on the
 validity.  TIA
 
 -Shawn
 
 I remember reading somewhere re: PHP coding that it is a better coding
 practice to use single quotes as much as possible vs. using double quotes in
 scripts. When using double quotes, you are forcing PHP to look for variables
 within them, even though there may not be any, thus slowing execution
 time...
 
 For example it is better to code:
   Code:
   echo 'td bgcolor='.$bgcolor2.'nbsp;/td/tr';
 
 vs.
   Code:
   echo td bgcolor=\$bgcolor2\nbsp;/td/tr;

Better is a very subjective question; however, style 1 will run faster
since it won't look for variable interpolation. Personally I always use
style 1 unless I specifically need variable interpolation or one of the
special characters such as a newline. Also when doing HTML the double
quotes fit nicely in the the single quote paradigm. On the other hand
when I do SQL queries, I often allow interpolation just because it is
more readable and because I usually use single quotes to wrap strings in
my queries.

HTH,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP code optimization

2002-07-11 Thread Richard Lynch

Question on optimizing code for quicker runtimes. 
Which is quicker (this is on a webpage also..NOT
commandline)?

?php if ($a){ echo 'abc'; } ?

OR

?php if ($a) { ? abc ?php } ?

You will not be able to measure the difference until you have a zillion of
them...

Both do the same thing and are legit but wondering
which is better from an optimization standpoint (NOT
interested in readability or *proper* code here)

Why not?!

It's *FAR* more important than raw performance 90% of the time!

Optimize the code that's slow, don't try to write all code at maximum
performance.

If we really needed all code at maximum performance, we'd all still be
coding in binary.

-- 
Like Music?  http://l-i-e.com/artists.htm


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] PHP code optimization

2002-07-09 Thread Peter Thoenen

Question on optimizing code for quicker runtimes. 
Which is quicker (this is on a webpage also..NOT
commandline)?

?php if ($a){ echo 'abc'; } ?

OR

?php if ($a) { ? abc ?php } ?

Both do the same thing and are legit but wondering
which is better from an optimization standpoint (NOT
interested in readability or *proper* code here)

-Peter

__
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP code optimization

2002-07-09 Thread Kevin Stone

I'm just guessing but I would think there would be no difference.  The only
way I think there would be a differnce is if you did many many echo
statements as opposed to one echo or one ?output block? becuase it would
have to parse that many more instances of the function.  Again.. just a
guess.
-Kevin

- Original Message -
From: Peter Thoenen [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, July 09, 2002 1:32 PM
Subject: [PHP] PHP code optimization


 Question on optimizing code for quicker runtimes.
 Which is quicker (this is on a webpage also..NOT
 commandline)?

 ?php if ($a){ echo 'abc'; } ?

 OR

 ?php if ($a) { ? abc ?php } ?

 Both do the same thing and are legit but wondering
 which is better from an optimization standpoint (NOT
 interested in readability or *proper* code here)

 -Peter

 __
 Do You Yahoo!?
 Sign up for SBC Yahoo! Dial - First Month Free
 http://sbc.yahoo.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP code optimization

2002-07-09 Thread Analysis Solutions

On Tue, Jul 09, 2002 at 12:32:59PM -0700, Peter Thoenen wrote:
 Which is quicker (this is on a webpage also..NOT
 commandline)?
 
 ?php if ($a){ echo 'abc'; } ?
 OR
 ?php if ($a) { ? abc ?php } ?

The difference is very marginal.  Write whichever makes more sense in the
context.  Short tidbits just don't matter.  Larger stretches of text are
easier to just send out as is rather than echo.

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP code optimization

2002-07-09 Thread Chris Shiflett

Peter Thoenen wrote:

Question on optimizing code for quicker runtimes. 
Which is quicker (this is on a webpage also..NOT
commandline)?

?php if ($a){ echo 'abc'; } ?

OR

?php if ($a) { ? abc ?php } ?


Because the difference is going to be undetectable, this would probably 
be a question that only someone really familiar with the engine would be 
able to answer with any sort of assurance.

My bet is that the second method is faster in theory, because switching 
in/out of PHP is likely marginally faster than executing the echo 
function. Maybe if you create some scripts that loop through these 
statements 10,000 times each and measure the time with microtime(), you 
can get a more affirmative answer and let the list know your results.

Happy hacking.

Chris


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP code optimization

2002-07-09 Thread Nick Oostveen

I could be wrong, but I seem to remember reading somewhere that using ? 
text ? is actually just shorthand for echo  text ; as far as the php 
engine itself is concerned.

Again I'm not positive, but if this is the case it would coincide with the 
comment made earlier that they are in fact the same speed, but that 
outputting a large amount of text through a single ? ? would be slightly 
faster than using numerous echo commands.

At 06:39 PM 7/9/2002 -0500, Chris Shiflett wrote:
Peter Thoenen wrote:

Question on optimizing code for quicker runtimes. Which is quicker (this 
is on a webpage also..NOT
commandline)?

?php if ($a){ echo 'abc'; } ?

OR

?php if ($a) { ? abc ?php } ?

Because the difference is going to be undetectable, this would probably be 
a question that only someone really familiar with the engine would be able 
to answer with any sort of assurance.

My bet is that the second method is faster in theory, because switching 
in/out of PHP is likely marginally faster than executing the echo 
function. Maybe if you create some scripts that loop through these 
statements 10,000 times each and measure the time with microtime(), you 
can get a more affirmative answer and let the list know your results.

Happy hacking.

Chris


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] code optimization

2001-09-15 Thread Christian Dechery

I just got (1:30 AM) something that was really annoying me.

I had to do it... but I got so into the I must do it thing I ended up 
doing it in an unoptimized way, I think.
I got to this conclusion for the amount of loops I'm using and the number 
of lines of code.

The problem is in my previous mail help with  nasty recursive algorithm...

I'm using 5 for(;;) loops, and it took 68 lines of code (including 3 small 
functions) to achieve it... it's kinda of too much, don't you think???

p.s: meu novo email é [EMAIL PROTECTED]

. Christian Dechery (lemming)
. http://www.tanamesa.com.br
. Gaita-L Owner / Web Developer


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