[英]localhost WordPress include file.php
在我的wordpress頁腳中,我從其他站點獲取文件php。
<?php include('http://www.othersite.com/1.php'); ?>
如何在本地主機上工作?
有錯誤:
Warning: include() [function.include]: URL file-access is disabled in the server configuration in D:\Design\AppServ\www\wordpress\wp-content\themes\mythems\footer.php on line 21
Warning: include(http://www.othersite.com/1.php) [function.include]: failed to open stream: no suitable wrapper could be found in D:\Design\AppServ\www\wordpress\wp-content\themes\mythems\footer.php on line 21
Warning: include() [function.include]: Failed opening 'http://www.othersite.com/1.php' for inclusion (include_path='.;C:\php5\pear') in D:\Design\AppServ\www\wordpress\wp-content\mythems\halongcruise\footer.php on line 21
謝謝
如果您只想獲取內容並將其顯示在頁腳上,請執行以下操作:
<?php
$response = wp_remote_get('http://www.othersite.com/1.php');
echo wp_remote_retrieve_body( $response );
?>
嘗試這個:
解決方案1:
在php.ini
上添加或取消注釋以下行:
allow_url_fopen = ON
重新啟動apache
。
解決方案2:
將以下內容添加到.htaccess文件中:
php_flag allow_url_fopen on
http://www.solo-technology.com/blog/2010/04/07/quick-fix-for-url-file-access-is-disabled-issues/
如果要包含來自其他服務器的文件,則需要允許包含遠程文件,必須在php.ini中將指令allow_url_include設置為On。 默認情況下,此設置在大多數Web服務器(php.ini)中是禁用/不允許的,因此出於安全原因,您不能使用include包含來自遠程地址的文件。
從面向安全的角度來看,這種做法是不好的。 因此,無論您想做什么,都請記住我要說的話。
如果您不想包含其他網站文件,則可以輕松地添加服務器中的文件,例如,
<?php include('1.php'); ?> //Use relative or absolute path inside include
參考: http : //phpsec.org/projects/phpsecinfo/tests/allow_url_include.html
用於包含文件
wp_remote_get( 'http://www.example.com/index.html' );
用於檢索您網站上包含的數據數據
wp_remote_retrieve_body()
您最終可以使用此波紋管代碼。
<?php
$get_include = wp_remote_get( 'http://www.example.com/myfile.php' );
echo wp_remote_retrieve_body($get_include);
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.