簡體   English   中英

我想在 php 上包含來自網絡的代碼。 示例:需要“domain.com/folder/file.php”;

[英]I want to include code from the web on php. Example: require "domain.com/folder/file.php";

我需要從我的網絡中包含一些變量和代碼,我使用了include "example.com/folder/file.php"; ,而且我無法從我的網絡中包含此文件。 我有一個付費托管。

我收到這些錯誤:

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”和“C:\\xampp\\htdocs\\folder\\file.php”是用於保護我的隱私的說明性網址)

我希望你能幫助我。 謝謝!

您也許可以將此行放在腳本的開頭

ini_set('allow_url_include',1);

如果這不起作用,請參閱如何定位 php.ini 文件 (xampp)並更新 php.ini 文件中的allow_url_include設置。

https://www.php.net/manual/en/filesystem.configuration.php

您的問題的可能解決方案——制作您自己的網絡服務:

// 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...
}

遠程腳本(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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM