Reputation: 177
How do I call a function which is in a different file without including or requiring that file?
Upvotes: 4
Views: 3457
Reputation: 6798
You can't. If you don't include or require it, PHP has no idea what's there. You can use .htaccess or php.ini to automatically include a file, which is identical to including it with require or include.
For example in .htaccess
php_value auto_prepend_file "/full/path/to/a/prepend-file.php"
In php.ini
auto_prepend_file = "/full/path/to/a/prepend-file.php"
Upvotes: 5
Reputation: 165606
Read it into a string and eval it.
$code = file_get_contents("somefile.php");
eval($code);
Upvotes: 3