【问题标题】:Get only HTML code out from a PHP file using PHP? [duplicate]使用 PHP 从 PHP 文件中仅获取 HTML 代码? [复制]
【发布时间】:2020-01-09 10:14:01
【问题描述】:

我有一个 PHP 文件,我只需要获取 HTML 代码来发送电子邮件。我在哪里使用file_get_contents(email.php); 它还可以获取 php 代码有什么方法可以只获取 HTML 吗?

<?php 
   $pid=20;
   $cid=30;
?>

<!DOCTYPE html>
<html>
    <head>
        <title>Promotion Email</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
  <p><?php $pid + $cid ?></p>
</body>

我只需要 HTML 我尝试过这样:

$body = file_get_contents("promotion-mail-contents.php");

【问题讨论】:

    标签: php html css


    【解决方案1】:

    是的,就像从外部调用它一样。

    $body = file_get_contents("http://www.yourdomain.com/promotion-mail-contents.php");
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-23
      • 1970-01-01
      • 1970-01-01
      • 2011-04-05
      • 2012-02-27
      • 1970-01-01
      • 2015-02-13
      • 2013-01-20
      相关资源
      最近更新 更多