dongshou6788 2011-10-30 21:00
浏览 80
已采纳

带有php文件的PHP file_get_contents

I'm using file_get_contents() to merge a template and separate content and output them together as a page.

The problem I'm having is that if either of these files have a PHP statement,

<?php
    echo "example";
?>

The PHP isn't actually run, and the statement just seems to be part of the markup:

enter image description here

I thought at first that the PHP at the file I'm loading wouldn't be run first, but then I made a test page with the following:

<?php
    echo file_get_contents("http://stackoverflow.com");
?>

And uploaded it here to see that it works fine (processes the PHP first).

Should I be using a different function maybe?

  • 写回答

1条回答 默认 最新

  • duang5049 2011-10-30 21:05
    关注

    You just need to include() the PHP file.

    Be wary of the security concerns.

    If you want to capture the file's output, use output buffering.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python