localhost WordPress include file.php



在我的wordpress页脚中,我正在从其他站点获取文件php。

<?php include('http://www.othersite.com/1.php'); ?>

如何在localhost中工作?

收到错误:

Warning: include() [function.include]: URL file-access is disabled in the server configuration in D:DesignAppServwwwwordpresswp-contentthemesmythemsfooter.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:DesignAppServwwwwordpresswp-contentthemesmythemsfooter.php on line 21
Warning: include() [function.include]: Failed opening 'http://www.othersite.com/1.php' for inclusion (include_path='.;C:php5pear') in D:DesignAppServwwwwordpresswp-contentmythemshalongcruisefooter.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

重新启动CCD_ 2。

解决方案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);
 ?>

最新更新