Globals for Addition of Two Numbers in PHP

Globals for Addition of Two Numbers in PHP. A PHP program to execute $Globals for sum/ addition of two numbers. In this program, we can declare the global to execute the program. In PHP, $GLOBALS is a superglobal variable that allows you to access global variables from anywhere in the script, including functions and methods. In PHP, all global variables are saved in a $GLOBALS[index] array. The name of the variable is saved in the index.

$a = 4;
$b = 5;
function sum()
$GLOBALS['c'] = $GLOBALS['a'] + $GLOBALS['b'];
echo $c;




Function in Php

In PHP, a function is a reusable piece of code that performs a certain operation. When called, functions can either return values or just conduct an action without returning any value. PHP includes around 700 built-in functions that accomplish various tasks. 

PHP offers us with two kinds of functions: Built-in functions: PHP comes with a plethora of built-in library functions. User Defined Functions: In addition to the built-in functions, PHP allows us to write our own customised functions, known as user-defined functions.