increment variable each time page gets called or opened?

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



Index

Question
7条回答
  •  北恋
    北恋 (楼主)
    2021-01-28 18:36

    It won't work as you think. PHP code is executed each time from start to finish - meaning that no variables are kept over from one run to the next.

    To get around this, you could use a session variable (this is a special sort of variable) which will keep a value in it that you could keep for each visitor to the site. This will however work for EACH VISITOR individually.

    If you want to increment the value for all users (you open the first one, it says 1, I open the second it says 2 and so on) you will need to either store it in a database (good option), write it out to a text file (not really a good option) or magic up some other way to keep it saved.

提交回复
热议问题