increment variable each time page gets called or opened?

后端 未结 7 1125
盖世英雄少女心
盖世英雄少女心 2021-01-28 17:57



Index

Question
7条回答
  •  [愿得一人]
    2021-01-28 18:30

    Every php script inside in a page is executed when you are loading this page. So everytime your script is executes line by line. You can not count page loading number by the process you are trying.

    you can follow one of the process below:

    1) you can save it to the database and each time when it is loading you can execute query to increment the count value.
    2) you can do it by session like this:

    session_start();
    if(isset($_SESSION['view']))
    {
     $_SESSION['view']=$_SESSION['view']+1;
    }
    else
    {
     $_SESSION['view']=1;
    }
    

提交回复
热议问题