Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

PHP Get Different Number On Page Refresh

This simple php script allow you to get different number on every page refresh. If you want to change value of your php variable on page refresh, this script will help you. Let say i have a default value 1 and want to change it for 2 on page refresh and again 2 to 1 on next page refresh.

if(!isset($_SESSION['changenumber'])){
    $_SESSION['changenumber'] = 1;
}
if($_SESSION['changenumber'] == 1){
    $_SESSION['changenumber'] = 2;
}else{
    $_SESSION['changenumber'] = 1;
}
echo $_SESSION['changenumber'];

Please support us, Like us on Facebook.

0 comments:

Post a Comment

 

Copyright @ 2017 HKBlog.