Reputation: 19
i have one big doubt, all the variables that we directly declare within php page like
<?php
$testing = "hello world";
if(isset($_GET['code'])){
$GLOBALS['testing'] = $_GET['code'];
}
function hello(){
echo $GLOBALS['testing'];
}
hello();
?>
are these variables shared between 2 independent requests ?, like suppose 100's of requests are executed concurrently, will these global variable values shared among them, do php create a fresh set of array for each request and maintains globals in them per request?
Upvotes: 0
Views: 43
Reputation: 44831
No, globals are specific to a particular request. If you need persistence across requests, you need sessions or another storage mechanism, whether flat files or a database.
Upvotes: 1