RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

From: Date: Tue, 06 Oct 2009 13:56:29 +0000
Subject: RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-298649@lists.php.net to get a copy of this message
> Does these behaves exactly? > for($i=0; $i<10; ++$i) > for($i=0; $i<10; $i++) different benchmarks showed ++$i is usually faster than $i++ In that loop case, yes, what's happen internally is exactly the same, $i will be from 0 to 9, in the other case obviously is not the same. but pre increment and post increment are truly basic stuff ... I don-t see all this need to study the case, it's pretty simple, as is that operation, in PHP. In other languages, could have been the same, rarely in scripting languages though, at least those with still primitive scalar values (int, float, string, bool) Regards _________________________________________________________________ Windows Live Hotmail: Your friends can get your Facebook updates, right from Hotmail®. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009

« previous php.general (#298649) next »