Function noodles do not eat outside the parameters announced?

there is a strange question
suppose I declare

$self = $_SERVER["PHP_SELF"];

then I wrote a function below

$self = $_SERVER["PHP_SELF"];

function report(){
    echo $self;
}

and then I"ll do another one

report();

he will say

Undefined variable: self

do I have to announce it in front of function?
this is the only way to make it work:


function report(){
$self = $_SERVER["PHP_SELF"];

    echo $self;
}
Mar.01,2021

$self = $_SERVER['PHP_SELF'];

function report(){
    global $self;
    echo $self;
}

you need to understand the root cause of the problem (the scope of php). The global variable of php is a global variable that cannot be accessed directly in the function

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5cbf5-27c0f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5cbf5-27c0f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?