【问题标题】:Executing PHP File and Putting Results In a String执行 PHP 文件并将结果放入字符串中
【发布时间】:2015-05-20 14:36:34
【问题描述】:

我有以下内容可以读取文件并分配给字符串:

$insert_html = file_get_contents('view.php');

view.php 文件本身看起来像:

<div>This is price of your item: <?php echo $price; ?></div>

但是,文件中的 PHP 并没有被执行。 eval()include 都没有给我想要的东西。最好的方法是什么?

【问题讨论】:

  • (quoted:) "eval() 和 include 都不能完全满足我的需求" 那你还在寻找什么?
  • 您可以查看此链接stackoverflow.com/questions/1272228/…
  • 这正是我想要的@littleibex。但第二个答案对我有用!
  • @GuillermoPhillips 是的,我也认为第二个答案更合适。
  • 你能改变你的view.php吗?

标签: php


【解决方案1】:

您可以使用$insert_html = exec('view.php');,但我认为这不是最好的方法。

问候。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-01
    • 2013-11-09
    • 2016-01-31
    • 2011-07-23
    • 1970-01-01
    • 2012-01-11
    • 1970-01-01
    相关资源
    最近更新 更多