开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜