Just return it....
function this() {
$number = 1;
return ($number);
}
$number = this();
print ($number);
Making it global is generally poor practice because it can lead to all sorts of niggling problems, and fixing them could require hunting through all your code to find all the places where $number might be getting set and/or used before you can find out why it hasn't got the value you expected it to have.
And of course it makes changes easier if you ever want to change this() to use different variable names:
function this() {
$wacky = 1;
return ($wacky);
}
$number = this();
print ($number);
still works as advertised.