开发者

How do I to include a file in php without using include or require?

开发者 https://www.devze.com 2023-03-03 06:47 出处:网络
How do I call开发者_Python百科 a function which is in a different file without including or requiring that file?You can\'t. If you don\'t include or require it, PHP has no idea what\'s there. You can

How do I call开发者_Python百科 a function which is in a different file without including or requiring that file?


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"


Read it into a string and eval it.

$code = file_get_contents("somefile.php");
eval($code);


Copy and paste it. But mind the license.

0

精彩评论

暂无评论...
验证码 换一张
取 消