I need to create some global variable in PHP through function dynamically to be used out of function
I tried
<?php
function setthis(newglobal){
global $_.newglobal._1;
$_.newglobal._1 = "pampam";
}
setthis();
echo $_newglobal_1;
?>
and I am getting this error
Line : 2, Error type : 4
Message : syntax error, unexpected ')', expecting '&' or variable (T_VARIABLE)
I also tried wrap them in quoted the variable like
<?php
function setthis(newglobal){
global $_.'newglobal'._1;
$_newglobal_1 = "pampam";
}
setthis();
echo $_newglobal_1;
?>
an I am getting error Message
: syntax error, unexpected ')', expecting '&' or variable (T_VARIABLE)
can you please let me know if this is doable in PHP? or what I am doing wrong?
Update
<?php
function setthis($name){
$GLOBALS[$name];
$name = "pampam";
}
setthis();
echo $name;
?>