How to bring variable from function's function in global use?

// Just a random file

function release($release) {


echo "This is it!: " . $skeletonName;
// skeleton.php

$skeletonName = "Boo";

Well I don’t know what the variable will be called. But if it’s created and it has it’s processing it should do that, and just set variable globally. Can it be done?

Generally a function will have a return at the end, for example:-

return $skeletonName ;

Then you could call the function like:-

$skeletonName = release("skeleton");

no (see your other thread for an explanation why). and I recommend to never use require/include to import global variables. I have spent hours searching where such an included global variable originates.

however you can use require/include to define variables.

// skeleton.php

// define the variable
$skeleton = 'some value';
// note the return statement here!
return $skeleton;
// import the data
function release()
    // again, note the return statement
    return require 'skeleton.php';

// define the variable in the current script
$skeletonName = release();

echo "This is it!: " . $skeletonName; // This is it!: some value

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.