PHP global Keyword

PHP if Keyword
PHP function Keyword

In this article, you will learn how to get the value from the variables having global scope.

examples of the GLOBAL function

Example 1. In this example, we use a global variable in a function.

<?php
$x = 5;
function add($y) {
  global $x;
  return $x + $y;
}

echo "$x + 5 is " . add(5);
?>
PHP if Keyword
PHP function Keyword

Stay up-to-date about PHP!

We don’t spam!

en English
X
Scroll to Top