PHP静态计数器?

n0p*_*0pe 1 php variables static

我正在尝试创建一个将保留计数的脚本,即使它被多次调用也是如此.这是为脚本写入文件的某些行提供唯一ID.

例如:

Monday I call the script and make 2 lines. The script gives ID 1 and 2 to those lines.
Friday I call the script again and make another line. The script gives ID 3 to this one.
etc
Run Code Online (Sandbox Code Playgroud)

Joh*_*ght 6

我建议使用MySQL的自动增量功能.

否则,存储一个平面文件以存储运行计数(并在使用时锁定它以避免并发问题).