<?php
$a ="helllo welcome to php! ....:)";
function msg(){
/* global $a; */
echo $a;
}
msg();
?>
Global variable $a is not accessible inside the function msg() but when i use global $a then it is accessible, i want to know that it is accessible or not without using global keyword inside or outside the function for the particular variable
✔ In python, it's accessible even without using the global keyword ✔
Why did you commented global $a
?
<?php
$a ="helllo welcome to php! ....:)";
function msg(){
global $a;
echo $a;
}
msg();
?>