繁体   English   中英

本地WordPress包含文件.php

[英]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.

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