I have always used $i++ since its the traditional way of incrementing a loop but upon further research it seems like using ++$i is a tad bit faster. An explanation of this is because $i++ makes a "copy" of $i then increment then return whereas ++$i increments $i then return it.
This bit of code will explain it a little clearer:
$i = 0;
$t .= "First instance: " . ++$i . PHP_EOL;
$t .= "Second instance: " . $i++ . PHP_EOL;
$t .= "Third instance: " . $i . PHP_EOL;
$i++;
$t .= "Fourth instance: " . $i . PHP_EOL;
print nl2br($t);
$t .= "First instance: " . ++$i . PHP_EOL;
$t .= "Second instance: " . $i++ . PHP_EOL;
$t .= "Third instance: " . $i . PHP_EOL;
$i++;
$t .= "Fourth instance: " . $i . PHP_EOL;
print nl2br($t);
This will print:
First instance: 1
Second instance: 1
Third instance: 2
Fourth instance: 3
Second instance: 1
Third instance: 2
Fourth instance: 3
As you can see, $i++ doesn't return the value right away; It makes a copy and return it at the end of the print execution where as ++$i returns the value of $i right away like what you can see in "First instance: 1"
5 comments:
moncler outlet, cheap oakley sunglasses, canada goose outlet, oakley outlet, ugg boots, ray ban outlet, oakley sunglasses cheap, ray ban, ray ban outlet, ray-ban, oakley sunglasses outlet, oakley outlet, cheap oakley sunglasses, oakley vault, ray ban sunglasses outlet, canada goose, oakley vault, louboutin, tn pas cher, cheap oakley sunglasses, ray ban, canada goose, ray ban, ugg, oakley sunglasses outlet, ray bans, raybans, canada goose, oakley vault, ray-ban, oakley outlet, cheap sunglasses, ralph lauren, rayban, cheap oakley, moncler, oakley sunglasses cheap, gucci, oakley sunglasses outlet, moncler, oakley, canada goose, cheap sunglasses, ray bans, cheap sunglasses, oakley sunglasses cheap, moncler, canada goose outlet, rayban, discount oakley sunglasses
ray ban sunglasses, http://www.raybansunglassesonline.us.com/
nike trainers, http://www.niketrainers.me.uk/
gucci handbags, http://www.guccihandbags-outlet.co.uk/
herve leger, http://www.herveleger.us.com/
timberland boots, http://www.timberlandboots.name/
coach outlet online, http://www.coachoutletonline-store.us.com/
michael kors outlet, http://www.michaelkorsoutletcanada.in.net/
juicy couture outlet, http://www.juicycoutureoutlet.net/
calvin klein underwear, http://www.calvinklein.in.net/
ray ban sunglasses, http://www.raybansunglass.us.com/
prada outlet, http://www.pradaoutlet.us/
lululemon outlet, http://www.lululemonoutletstore.in.net/
tory burch shoes, http://www.toryburchshoesoutlet.com/
michael kors outlet, http://www.michaelkorsoutlet.org.uk/
replica watches, http://www.replicawatchesforsale.us.com/
pandora jewelry, http://www.pandorajewelryoutlet.us.com/
nfl jerseys wholesale, http://www.nfljerseys-wholesale.us.com/
michael kors outlet, http://www.michaelkorsoutletonlinstore.us.com/
oakley outlet, http://www.oakleyoutlet.in.net/
oakley sunglasses, http://www.oakleysunglasses-outlet.us.com/
michael kors bags, http://www.michaelkorsbags.uk/
ray ban sunglasses, http://www.ray-bansunglasses.eu.com/
oakley sunglasses, http://www.oakley.in.net/
air max 2015, http://www.airmax2015.in.net/
the north face uk, http://www.thenorthfaces.org.uk/
swarovski outlet, http://www.swarovski-outlet.co.uk/
pandora jewelry, http://www.pandora.eu.com/
chanel handbags, http://www.chanelhandbags-outlet.co.uk/
1002maoqiuyun
chenlina20151127
ugg boots sale
oakley sunglasses
louis vuitton handbags
ray ban sunglasses outlet
chanel handbags
air force 1
christian louboutin shoes
pandora outlet
the north face outlet
cheap air max
oakley sunglasses
jordan retro
nike free runs
uggs outlet
oakley outlet
jordans for sale
ugg boots outlet
christian louboutin outlet
the north face outlet
louis vuitton purses
louis vuitton outlet
jordan concords
louis vuitton outlet
louis vuitton outlet
ugg boots
uggs on sale
ugg boots
louis vuitton
louboutin pas cher
christian louboutin
coach factory outlet
gucci outlet
ugg slippers
running shoes
swarovski outlet
coach outlet store online
official coach factory outlet
uggs outlet
air jordans
canada goose outlet
as
adidas nmd
michael kors handbags outlet
nike trainers uk
michael kors
atlanta falcons jersey
detroit lions jerseys
reebok shoes
miami heat jersey
michael kors outlet clearance
replica rolex
snapbacks wholesale
gucci outlet online
coach outlet online
cheap oakley sunglasses
michael kors outlet online
ralph lauren outlet
michael kors outlet clearance
pandora jewellery
cheap ray ban sunglasses
michael kors outlet clearance
20170617lck
Post a Comment