// Just a random file
function release($release) {
require_once("$release.php");
}
release("skeleton");
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?
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.
<?php
// 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