A
A
Adil16032020-05-07 19:15:45
PHP
Adil1603, 2020-05-07 19:15:45

How to display the sum of global variables?

How to write a function that will display the sum of global numbers.

my code is like this but not working

$a = 5;
$b = 10;

function summa(){

    $summan = $GLOBALS['a'] + $GLOBALS['b'];
    return $summan;
  }

summa();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ildar Saribzhanov, 2020-05-07
@Bluz

Try
summa();
replacing with
var_dump(summa());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question