Let me preface this with, I come from a Java background.
What is the scope of a static class member in PHP? ie: Request, Session, Server Lifecycle, etc
My current understanding is that everything is Request unless it is stuck on the session. I have found nothing in the Language Guide to refute or confirm this.
Example
class MyKlass {
public static $K_PAGE_SIZE = 50;
public static $K_WITH_SPRINKLES = true;
}
if (isset($_GET['NO_SPRINKLES'])) {
MyKlass::$K_WITH_SPRINKLES = false;
}
var_dump(MyKlass::$K_WITH_SPRINKLES);
Case 1
If I were to visit a page with this code with nothing in the query line I should see
bool(true)
Case 2
If I were to visit the page with this code and ?NO_SPRINKLES=true
in the query line, I should see
bool(false)
Case 3
If I visit the page with ?NO_SPRINKLES=true
in the query line and then visit the page without it, I should always see bool(true)
right?
Case 4
After visiting the page with ?NO_SPRINKLES=true
, others who visit the page should still see bool(true)
correct?