Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,190,610 members, 7,941,346 topics. Date: Friday, 06 September 2024 at 02:13 AM

Grandtheft's Posts

Nairaland Forum / Grandtheft's Profile / Grandtheft's Posts

(1) (of 1 pages)

Programming / Re: Some optimization tips for php by grandtheft: 8:51am On Sep 21, 2013
Use str function over most regex functions. Except you really require a regex.
Programming / Re: Some optimization tips for php by grandtheft: 8:23am On Sep 21, 2013
Also do not do mysql queries in a loop, you can store all the queries in a variable in the loop then do the query outside the loop
Programming / Re: Some optimization tips for php by grandtheft: 6:47am On Sep 21, 2013
pc guru:
so if am to understand you, in order to gain performance i should write all my codes in one file and not use classes, no thanks __autoload and SPLAutoloaders only activate when a class is called, i haven't encountered any performance issue on my part here besides its PSR-0 its the standard all my projects at work are OOP anyway so i don't know much about procedural projects.
he didn't say All you code.
Programming / Re: Some optimization tips for php by grandtheft: 7:02am On Sep 20, 2013
4)Rather than search an array for a value. Why not make the value the key then use the isset method ?. Here is what am saying:
<?php
$arr = array('apple' => 1, 'pineapple' => 1, 'orange' => 1, 'mango' => 1, 'pawpaw' => 1);
echo (isset($arr[$_GET['fruitname']]) ? 'Fruit Found' : 'Fruit Not Found');
?>
that is better, we all know isset is very fast. That was the same technique i used to build the unofficial .

5)copying variables just because you want a shorter name is totally wrong. Except you have a reason, because it consumes more space for nothing.
Programming / Some optimization tips for php by grandtheft: 6:33am On Sep 20, 2013
1) ++$i is faster than $i++. You should use this is scenarios where it doesn't matter if you do a post or pre increment, because both of they are not the same. Same applies to pre decrement and post decrement.
2)Single quotes is faster than double quote because php searches for variables in a double quote. If you don't have variables in the double quotes consider changing it to single quotes.
3) for($i = 0; $i < count($arr); $i++) { is very bad because the count function gets called on each iteration. Rather declare a variable outside the loop like this: $count = count($arr); for($i = 0; $i < $count; $i++) {

(1) (of 1 pages)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 8
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.