I want to be able to call function from anywhere. So i could just write something like this: file.php:foo();. Is it possible?
This may not be a solution for you, but it might. You could wrap your functions into namespacing classes.
You could add a class called file with foo as a static function. So instead of calling foo(), you'd call file::foo(). You would then __autoload those namespaced classes. To do that, you would have to somewhere define your autoload function, something like:
function __autoload($class_name) {
include $class_name . '.php';
}
And then your file.php would look like:
class file {
public static function foo() {
//do stuff
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With