+ 1

in this program why variable c access outside of the function..if i put echo $c within function then give some error.

<?php $x=50; $y=20; function sum() { $GLOBALS['c']=$GLOBALS['x']+$GLOBALS['y']; } sum(); echo $c; ?>

15th Feb 2019, 4:42 AM
SOUVIK RAY BARMAN
SOUVIK RAY BARMAN - avatar
1 Answer
0
Your code was good.in your code their was a return so the output is returning to the function.if you want to print with in function than than can be possible. But in my code if I want to print global variable c with in function than give some error.
27th Feb 2019, 4:09 AM
SOUVIK RAY BARMAN
SOUVIK RAY BARMAN - avatar