The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
static variable in plugin is not static, always gets re-initialized - problem solved.
Created a plugin at the parse_templates hook. Every time the screen is refreshed it keeps echoing '0', and does not increment as expected - 0, 1, 2, 3, 4, 5, 6...
Help? function Test() { static $a = 0; $a++; echo $a; } Test(); --------------- Added [DATE]1222142702[/DATE] at [TIME]1222142702[/TIME] --------------- Quote:
function Test() { static $a = 0; $a++; echo $a; } Test(); Test(); Test(); Test(); Will indeed output 1, 2, 3, 4 etc. When a page is refreshed it re-initializes the variable "a" to 0. Seems static variables could be useful but not for what I am trying to accomplish, "session variable" is what might work best. More information over here: https://vborg.vbsupport.ru/showthrea...ble#post255557 --------------- Added [DATE]1222142845[/DATE] at [TIME]1222142845[/TIME] --------------- The "Auto-Merged DoublePost " feature of vBulletin.org is interesting, not sure that is something I can appreciate though. |
#2
|
||||
|
||||
HTTP is a stateless protocol - it doesn't know what you've done before. I think you need to have a look at how the PHP "static" keyword works.
|
#3
|
|||
|
|||
Quote:
My goal is a simple counter that keeps track of how many times people click refresh on a page as a simple exercise to learn how this stuff works. I've read PHP.net, w3schools.com, and several other of the links in the resource sticky. In addition have spent many hours searching this forum & vB.com forums. If you have further input on how to learn I'm interested. |
#4
|
||||
|
||||
Quote:
Each HTTP request is treated as an individual. |
#5
|
|||
|
|||
Understood, thank you very much.
:up: |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|