I can't understand how they operate global variables in this language, I read the documentation and everything is explained clearly, but when I go to apply via this code does not work. Probably something I'm wrong, help me to correct.
I declare a variable within the spreadsheet php, I call the variable $pubblica
at this point I'm going inside a function to insert the content in this way:
function add()
{
$GLOBALS['pubblica'] = "insert name";
}
I imagine that the content of the variable $pubblica
now is: "insert name"
I therefore the need to use the variable with this content inside another function like this:
function esplore()
{
echo "Contents of variables is $pubblica";
}
Should print me this content: "insert name"; But I get a blank message, and do not understand why. What's wrong with that?
UPDATE QUESTION:
<?php
$GLOBALS['pubblica'];
function add()
{
$GLOBALS['pubblica'] ="insert name";
}
function esplore()
{
echo "Contents of variables is " . $GLOBALS['pubblica'];
}
?>
the add function is activated when you press a button, and within this is called esplore