Lets use this as our import file.
<?php
// alpha.php
$alpha = 'abcdefghijklmnopqrstuvwxyz';
function alpha() {
global $alpha;
return $alpha;
}
function rev_alpha() {
global $alpha;
return strrev($alpha);
}
?>
Now lets utilize this file as an import.
<?php
$alpha = import('alpha.php');
// echoes abcdefghijklmnopqrstuvwxyz
echo $alpha->alpha;
// echoes abcdefghijklmnopqrstuvwxyz
echo $alpha->alpha();
// echoes zyxwvutsrqponmlkjihgfedcba (did I type that right?)
echo $alpha->rev_alpha();
?>
Internally:
global $alpha;
Is changed to:
$imported = import('alpha.php');
$alpha = $imported->alpha;
Now lets say we only want alpha characters in a phone number, aka no z or q.
<?php
$alpha = import('alpha.php');
$alpha->alpha = 'abcdefghijklmnoprstuvwxy';
// echoes yxwvutsrponmlkjihgfedcba
echo $alpha->rev_alpha;
?>
See the power?
The import() function internally keeps track of Import classes to make sure the same file isn't imported twice (which would cause naming collisions).
If you want to make a copy of an import you can simply do:
$imp = import('foo.php');
$imp_copy = $imp;
Take note that if anything in $imp was changed before it was copied to $imp_copy that $imp_copy also receives those changes. Currently there is no way to reset values... although that could change in the future.
It is possible to have the same function names and class names in imported files. All the functions and classes are internally uniquely prefixed to avoid name collisions.
------
this is just some documentation on the functionality... and more functionality is to be added.