Well unfortunately you, as far as I know, need to either declare it in the global scope or use a definition. That doesn't mean you can't use some tricks to make it easier, though. Let's take a look at the not example:
Say your file
programming-file.php has three variables:
PHP Code:
<?php
$apples = "fruit";
$oranges = "delicious";
$pasta = "noodle";
?>
In your process_data method you'll need to do:
PHP Code:
<?php
public function process_data() {
global $apples, $oranges, $pasta;
include 'programming-file.php';
}
?>
However that doesn't mean you need to spend a bunch of time declaring variables in the global scope. Since I use a custom template system I often need to send output to a file. So what I'll do is store everything in an array. Example:
Instead of the way we saw above, we do this:
PHP Code:
<?php
$globalVars['apples'] = "fruit";
$globalVars['oranges'] = "delicious";
$globalVars['pasta'] = "noodle";
?>
Then all we need to do in process_data is:
PHP Code:
<?php
public function process_data() {
global $globalVars;
include 'programming-file.php';
}
?>
Other than that the only thing that I think will accomplish it is something like a register_globals() which is a very insecure method to use.
Hope this helps!