且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

每次页面被调用或打开时增量变量?

更新时间:2023-11-25 08:20:34

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;
}