PHP Optimization

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

PHP Optimization

Post by Chris Corbyn »

Is anyone willing to provide a short list of hints and tips to keep your PHP scripts running as fast and reliably as possible?
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

tip1:
echo '';
is faster than
print "";

tip 2:
Dont use sloppy code

tip 3:
dont do something more than once (ie assigning variables, unessicary db connects ect)

tip 4

tip 5: profit

thoes are all the ones i can think of right now...im sure i have more
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

How to..

Post by Roja »

Better minds than mine have already answered:

http://phplens.com/lens/php-book/optimi ... ng-php.php
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Does anyone know if reducing the number of echo's is faster or sloppier?

For example:

Code: Select all

echo '<table>';
echo '<tr>';
echo '<td>';
echo 'Some text';
echo '</td>';
echo '</tr>';
echo '</table>';
compared to

Code: Select all

echo '<table>
<tr>
<td>
Some text
</td>
</tr>
</table>';
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Oh and another question....

When I'm writing my php code I just use windows notepad. It's not particularly friendley for debbugging even when the code is nicely laid out.

On this forums php code is shown nicely color coded which makes things easier.

Anyone know of any software which lets you write your php so that it's viewable in color coded form like on this forum?
piccaso
Forum Newbie
Posts: 2
Joined: Tue Apr 13, 2004 3:39 pm
Location: Austria (Vienna)

Post by piccaso »

im using Macromedia Dreamweaver MX 2004, its qite nice but not free.
Im sure you will find something usefull here http://www.thelinuxconsultancy.co.uk/ph ... /index.php
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

to d11wtq...
there is a whole discussion on editors in the general discussion section, look at that
User avatar
MarK (CZ)
Forum Contributor
Posts: 239
Joined: Tue Apr 13, 2004 12:51 am
Location: Prague (CZ) / Vienna (A)
Contact:

Post by MarK (CZ) »

I use ActiveState Komodo (http://www.activestate.com/). Paid, but good.

Anyway, you can highlight the code using php via functions highlight_file or highlight_string.
ElKyle
Forum Newbie
Posts: 1
Joined: Tue Apr 13, 2004 4:16 pm

My editor

Post by ElKyle »

I use Crimson Editor...free :D Also has no shareware messages, just pure, unadultered, old-fashioned freeware. :)

Go to http://www.crimsoneditor.com

Color-codes for many diff. types of code, including PHP, ASP, Perl, and HMTL. Defaults are diff. colors than this site or php.net uses, but those are adjustable. Also, it automatically indents all lines between { and }...good for those of us that don't want to take the time to manually indent.
RadixDev
Forum Commoner
Posts: 66
Joined: Sun Mar 14, 2004 11:27 am
Location: U.K.

Post by RadixDev »

If you want a strong debuggin feature go with PhpEd
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

I prefer Zend Studio.

http://www.zend.com
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

kazaa + nortons personal firewall 2004/anti virus = dreamweaver mx 2004 :)
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

Phenom wrote:kazaa + nortons personal firewall 2004/anti virus = dreamweaver mx 2004 :)
psssst. be quiet 8) :idea:
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Crimson editor looks cool. Just got it. At least it's free and you can customize all the colors it uses. Works for a whole host of languages too.

I should check out some others before I recommend it over anything else but I have to say, for a freeware program its pretty nice
mishal
Forum Newbie
Posts: 12
Joined: Sat Apr 10, 2004 4:23 pm

Post by mishal »

d11wtq wrote:Does anyone know if reducing the number of echo's is faster or sloppier?
In some php references i read, the following ways is much faster than both of your ways because php will never spend time to parse them, e.g. :

Code: Select all

<?
some php codes ....
...
?>
<table>
  <tr>
    <td>Some text
    </td>
  </tr>
</table>
<?
some php codes
..
?>
Post Reply