Re: Whacky increment/assignment logic with $foo++ vs ++$foo

From: Date: Fri, 02 Oct 2009 21:45:21 +0000
Subject: Re: Whacky increment/assignment logic with $foo++ vs ++$foo
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-298493@lists.php.net to get a copy of this message
On Fri, Oct 2, 2009 at 17:42, Daniel Brown <danbrown@php.net> wrote: > >    .... but rather by something just slightly more advanced: > > <?php > $num = file_get_contents('visitcount.txt'); > if(isset($_GET['countme'])) { >    echo "You are visitor #".++$num."<br />\n"; >    file_put_contents($num); > } > ?> Converse example (sorry, forgot to add it): <?php $num = file_get_contents('visitcount.txt'); if(isset($_GET['countme'])) { echo "There were ".$num++." people here before you.<br />\n"; file_put_contents($num); } ?> -- </Daniel P. Brown> daniel.brown@parasane.net || danbrown@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Check out our great hosting and dedicated server deals at http://twitter.com/pilotpig

« previous php.general (#298493) next »