drtwqc3744 2013-12-25 22:53
浏览 80

如果文件包含include命令,则file_get_contents方法不起作用

I have a wordpress project. I tried to get the written content of php file with the file_get_contents, but it has got a problem, because the getting file has an include command, and this do the warning...

I have to use the file_get_contents() method, because I use an other online API, which work with this method!

In my file I use this file_get_contents() in the service.php:

$url = "http://localhost/davetips/sms_service.php";
$content = file_get_contents($url);
var_dump($content);
die();

And here the beginning of content of the "http://localhost/davetips/sms_service.php":

<?php
// Wordpress
global $wpdb;
include 'wp-blog-header.php';
echo "test";

error_reporting(E_ALL);
ini_set("display_errors", 1);

// Password constans
$option_password_text_key = 'password_storer_text';
// And more code ...

This php file didn't throw any warning or error, if it is run in directly from the url. It write out the "test" message in the browser.

If I wanna get this file by file_get_contents() from the first file. I get this problem:

Warning: file_get_contents(`http://localhost/davetips/sms_service.php`): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in /var/www/wp-tutorial/service.php

If I comment out the include command, it will be ok!

So I don't know, how I should include the wp-blog-header.php in the sms_service.php...

Does anyone has got a good advise?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计