Wordpress PHP在使用file_get_contents时注释掉了


Wordpress PHP commented out when using file_get_contents

以下wordpress快捷代码放置在single.php 中时行为正确

<?php echo do_shortcode( '[contact-form-7 id="13" title="KB EN Contact"]' ); ?>

但是,当将其放置在另一个文件中并使用:时

<?php echo file_get_contents("en-contact.php", 1);?>

php显示为注释掉的HTML。周围的HTML元素将正确显示。

<section id="contact-after-post" class="clearfix">
    <h3 id="contact-after-post-title">Didn't find what you were looking for?</h3>
      <div id="contact-after-post-number">
      </div>
      <div id="contact-after-post-number-click">
        <div id="number-left">
        </div>
        <div id="number-right">
        </div>
      </div>
      <div id="contact-after-post-form">
<!--?php echo do_shortcode( '[contact-form-7 id="13" title="KB EN Contact"]' ); ?-->
      </div>
</section>

为什么会发生这种情况?为什么行为会随着外部文件而改变?

您可以尝试include()函数而不是file_get_contents()。

代码:

<?php include("en-contact.php");  ?>