简体   繁体   中英

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"; , 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)

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 .

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)

// load your initialization, or just set
$version = '1.3.0';

header('Content-Type: application/json');
echo json_encode(['version'=>$version]);
die;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM