PHP里面的PHP代码

时间:2016-02-19 20:40:52

标签: php html wordpress

我正在使用Wordpress主题项目,我需要帮助。如何添加页面slug名称作为php导入文件的名称?

示例:

( <?php echo basename(get_permalink()); ?> - This gets the page slug name  )

<?php include '(slug name).php'; ?>
=
<?php include '<?php echo basename(get_permalink()); ?>.php'; ?>

2 个答案:

答案 0 :(得分:4)

includeecho都是PHP语句,不需要将它们包装在PHP标记中两次。

<?php include basename(get_permalink()) . '.php'; ?>

答案 1 :(得分:1)

<button class="btn btn-primary" type="button" data-toggle="collapse" data-  target="#collapseExample" aria-expanded="true" aria-controls="collapseExample">
    Button with data-target
</button>
<div class="collapse in" id="collapseExample">
     <div class="well">
      asf sdf adsf asdf fd asdf
     </div>
</div>