Programming Code Center(PCC)
[PHP]

(PCC)::[How-to-Use-the-global-keyword-to-access-a-global-variable-from-within-a-function-in-php]::[php]

File Name : index.php

<!DOCTYPE html>
<html>
<body>

<?php
$x = 5;
$y = 10;

function myTest() {
    global $x, $y;
    $y = $x + $y;
} 

myTest();  // run function
echo $y; // output the new value for variable $y
?>

</body>
</html>

Output :