Static variables in PHP are different for each user that makes a connection to the PHP page. How come this is so if a static variable is supposed to be… well, static?
That leads me to the second part of this question: is there a way to create a global static variable that is shared across all connections?
Static variables are only static and available within a specific scope of execution. Once the Apache thread that spawned that instance of PHP is destroyed, that static variable is removed from memory. Since a second user hitting your web server would mean that Apache loads up a new thread, spawning a brand new instance of PHP, which runs within its own scope. Therefore, the static variable defined in the first thread isn’t available in the second.