PHP/Html文件转换为Html文件


PHP/Html file into a html file

我是编码等方面的新手,所以我想从你们那里得到一些帮助。我必须将每个文件(.php)放在一个.html/php文件中。

现在我得到了这个代码:

    <html>
<head>
    <style type='text/css'>
        span {
            text-decoration:underline;
            color:blue;
            cursor:pointer;
        }
    </style>
    <script>
        // show the given page, hide the rest
        function show(elementID) {
            // try to find the requested page and alert if it's not found
            var ele = document.getElementById(elementID);
            if (!ele) {
                alert("no such element");
                return;
            }
            // get all pages, loop through them and hide them
            var pages = document.getElementsByClassName('page');
            for(var i = 0; i < pages.length; i++) {
                pages[i].style.display = 'none';
            }
            // then show the requested page
            ele.style.display = 'block';
        }
    </script>

</head>
<body>
  <p>
    Show page 
        <span onClick="show('Page1');">1</span>, 
        <span onClick="show('Page2');">2</span>, 
        <span onClick="show('Page3');">3</span>.
    </p>
<div id="Page1" class="page" style="">
    Content of page 1
</div>
<div id="Page2" class="page" style="display:none">
    Content of page 2
</div>
<div id="Page3" class="page" style="display:none">
    Content of page 3
</div>
</body>

所以我的问题是;如何将我的文件放入"第1/2/3页的内容"?

提前感谢!

尝试include("[path to your file]");include_once("[path to your file]");

http://php.net/manual/en/function.include.php

http://php.net/manual/en/function.include-once.php

如果您需要将其他PHP文件与此HTML文件组合,只需将此文件的名称更改为.php(如果还没有)。然后将您的代码(按处理每个文件的顺序)复制/粘贴到该文件的顶部。确保用<?php?>包围您的php。如果HTML位于PHP文件中,它仍然可以正确显示。

注意:这不是一个好的做法,但它会满足你的老师的要求。