[英]I want to include code from the web on php. Example: require "domain.com/folder/file.php";
I need to include some variables and code from my web, I used include "example.com/folder/file.php";
我需要从我的网络中包含一些变量和代码,我使用了
include "example.com/folder/file.php";
, and I can't include this file from my web. ,而且我无法从我的网络中包含此文件。 I have a paid hosting.
我有一个付费托管。
I get these errors:我收到这些错误:
Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in
C:\xampp\htdocs\folder\file.php on line 8
W arning: include(http:/example.com/folder/file.php): failed to open
stream: no suitable wrapper could be found in
C:\xampp\htdocs\folder\file.php on line 8
Warning: include(): Failed opening 'http://example.com/folder/file.php'
for inclusion (include_path='C:\xampp\php\PEAR') in
C:\xampp\htdocs\folder\file.php on line 8
("example.com/folder/file.php" and "C:\\xampp\\htdocs\\folder\\file.php" are illustrative urls for protect my privacity) (“example.com/folder/file.php”和“C:\\xampp\\htdocs\\folder\\file.php”是用于保护我的隐私的说明性网址)
I hope you can help me.我希望你能帮助我。 Thanks!
谢谢!
You might be able to put this line at the beginning of the script您也许可以将此行放在脚本的开头
ini_set('allow_url_include',1);
If this does not work, refer to How to locate the php.ini file (xampp) and update the allow_url_include setting in the php.ini file .如果这不起作用,请参阅如何定位 php.ini 文件 (xampp)并更新 php.ini 文件中的allow_url_include设置。
https://www.php.net/manual/en/filesystem.configuration.php https://www.php.net/manual/en/filesystem.configuration.php
Possible solution to your problem— make your own web service:您的问题的可能解决方案——制作您自己的网络服务:
// local script
$localVersion = '1.0.0';
$remoteVersion = '';
// get remote version as json
if( $remote = json_decode(file_get_contents('http://example.com/version.php')) {
// $remoteVersion=$remote['version'];
$remoteVersion=$remote->version
}
if( $localVersion < $remoteVersion ) {
// do whatever...
}
Remote script (version.php)远程脚本(version.php)
// load your initialization, or just set
$version = '1.3.0';
header('Content-Type: application/json');
echo json_encode(['version'=>$version]);
die;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.