incrementation
Posted: Thu Oct 14, 2010 1:12 pm
Here is the the code that's making me go a little mangos, not bananas. If someone could...
Ok! question: Why is it that when I echo $_SESSION['counter']+=1, idon't get to see the following line: <em><b>times</b></em>"; , on my browser but , echo "<em><b>You have viewed this page</b></em> " . $_SESSION['counter']++ . " <em><b>times</b></em>"; works just fine.
Thanks
Code: Select all
<?php
// initialize a session
session_start();
if(isset($_SESSION['counter'])){
//echo "<em><b>You have viewed this page</b></em> " . $_SESSION['counter']++ . " <em><b>times</b></em>";
echo "<em><b>You have viewed this page</b></em> ". $_SESSION['counter']+=1 ." <em><b>times</b></em>";
}else{
echo "<em><b>You have only viewed this page</b></em> " . $_SESSION['counter']=1 . " <em><b>times</b></em>";
}
?>Thanks