php - How to echo alternatively 2 values on every refresh? -
i'm writing php code , have 2 variables $var1
, $var2
. want method helps me display alternatively on every refresh 1 of 2 values.
for example:
on first load of page must display: echo $var1
on first refresh of page must display: echo $var2
on sec refresh of page must display: echo $var1
on 3rd refresh of page must display: echo $var2
etc...
for illustration can utilize sessions.
<?php session_start(); $a = 1; $b = 2; if(!isset($_session['variable'])){ $_session['variable'] = true; } if($_session['variable']){ echo $a; }else{ echo $b; } $_session['variable'] = !$_session['variable']; ?>
php variables echo
No comments:
Post a Comment