在PHP中包含带有表格的HTML文件

时间:2016-01-17 07:48:26

标签: php html wordpress

我有一个存储在HTML文件中的表,我想将其插入到WordPress页面中。我使用echo file_get_contents('table.html')但它没有显示任何内容。然后我尝试了echo htmlentities (file_get_contents('table.html'))。这只是将HTML代码输出到页面中,但不呈现它。如何正确显示表格?

HTML表格如下:

<table class="fao-pricing-table-additional">
 <tr>
    <th class="fao-table-plan-details-header" rowspan="2">Plan Details</th>
    <th class="fao-table-plan-starter-header">STARTER</th>
    <th class="fao-table-plan-business-header">BUSINESS</th>
    <th class="fao-table-plan-enterprise-header">ENTERPRISE</th>
    <th class="fao-table-plan-corporate-header">CORPORATE</th>
</tr>
<tr>.......

2 个答案:

答案 0 :(得分:1)

您可以使用include()语句在网页上呈现HTML / PHP

示例

<div>
  <p>The table will be between this paragraph</p>

    <?php 
        include("table.html");
    ?>

  <p>And this paragraph</p>
</div>

答案 1 :(得分:0)

使用' ./ '表示文件的相对路径。

示例: 回声file_get_contents(“ ./ table.html”);