You are here: Re: Does PHP have an end-of-file problem. « PHP Programming Language « IT news, forums, messages
Re: Does PHP have an end-of-file problem.

Posted by Curtis on 12/28/06 02:54

Just curious, but George, have you programmed in C or C++ before?

For what it's worth, here are some things you can do to increase
performance a bit. In PHP, strings do not need to have double quotes
unless they contain variables or whitespace metacharacters like \t, \n,
\r, etc. If you switch to single quotes, the PHP interpreter won't
execute variable interpolation on strings on which it's not needed.

>if (!$mysql=mysql_connect($host, $user, $password)) {
> printf("Connect failed: %s\n", mysql_connect_error());
> exit();
>
> mysql_close($mysql);
>}
Not related to performance, but after exit() is called, nothing is
executed, so there's no need to close the connection, unless you do it
before. At the very least, you'll get rid of a couple extra lines :P

You also call mysql_fetch_array, which generates two arrays, one
indexed, and one associative array (hash, dictionary, etc.). If you
call mysql_fetch_assoc() instead, you'll also save some time.

I guess this wouldn't affect you too much, unless you had an enormous
amount of data to sort through.

Curtis

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация