简体   繁体   English

本地WordPress包含文件.php

[英]localhost WordPress include file.php

In my wordpress footer I'm getting file php from other site. 在我的wordpress页脚中,我从其他站点获取文件php。

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

How to working this in localhost ? 如何在本地主机上工作?

Got errors: 有错误:

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

Thanks 谢谢

If you just want to get content and show it on your footer, here we go: 如果您只想获取内容并将其显示在页脚上,请执行以下操作:

<?php 

    $response = wp_remote_get('http://www.othersite.com/1.php');
    echo wp_remote_retrieve_body( $response );

?>

try this: 尝试这个:

SOLUTION 1: 解决方案1:
Add or uncomment the following line on your php.ini : php.ini上添加或取消注释以下行:

allow_url_fopen = ON

restart apache . 重新启动apache

SOLUTION 2: 解决方案2:

Add the following to the .htaccess file: 将以下内容添加到.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/ http://www.solo-technology.com/blog/2010/04/07/quick-fix-for-url-file-access-is-disabled-issues/

If you want to include file from different server, then you need to allow inclusion of remote files, the directive allow_url_include must be set to On in php.ini . 如果要包含来自其他服务器的文件,则需要允许包含远程文件,必须在php.ini中将指令allow_url_include设置为On。 By default this setting is disabled/not allowed in most web servers (php.ini) so you can not use the include to include the files from a remote addresss for security reasons. 默认情况下,此设置在大多数Web服务器(php.ini)中是禁用/不允许的,因此出于安全原因,您不能使用include包含来自远程地址的文件。

On a security-oriented point of view this practice is bad. 从面向安全的角度来看,这种做法是不好的。 So whatever you want to do just keep in mind what I'd try to say. 因此,无论您想做什么,都请记住我要说的话。

If you don't want to include another sites file then it is simple to include a file from your server like, 如果您不想包含其他网站文件,则可以轻松地添加服务器中的文件,例如,

<?php include('1.php'); ?> //Use relative or absolute path inside include

Reference: http://phpsec.org/projects/phpsecinfo/tests/allow_url_include.html 参考: http : //phpsec.org/projects/phpsecinfo/tests/allow_url_include.html

For include file use 用于包含文件

wp_remote_get( 'http://www.example.com/index.html' );

for retrieve included data data on your site 用于检索您网站上包含的数据数据

wp_remote_retrieve_body()

You can use for finally this issue bellows code. 您最终可以使用此波纹管代码。

<?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