简体   繁体   中英

echo not showing up on my php page?

Here is my code for my home page. I am trying to test php is working with 'echo' but the echo text doesn't show up on the homepage. I have saved the file as php but the echo "recent posts 1" does not show up on the page

<head>
<title>1WD HTML5 theme</title>
<meta charset="utf-8" />

<link rel="stylesheet" href="style.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<header class="mainHeader">
    <img src="img/logo.png">
    <nav><ul>
        <li class="active"><a href="#">Home</a></li>
        <li><a href="#">Forum</a></li>
        <li><a href="#">Login</a></li>
        <li><a href="#">Sign up</a></li>
    </ul></nav>
</header>

<div class="mainContent">
    <div class="content">   
            <article class="topcontent">    
                <header>
                    <h2>Recent Posts</h2>
                </header>


                <content>
                        <?php
                echo "recent post 1";
                echo "recent post 1";
                echo "recent post 1";
                echo "recent post 1";
                echo "recent post 1";
                echo "recent post 1";
                echo "recent post 1";
                echo "recent post 1";
                echo "recent post 1";
                echo "recent post 1";
                echo "recent post 1";
                ?>

                </content>

            </article>


    </div>

            <aside class="top-sidebar">
                <article>
                <h2>Top Sidebar</h2>
                <p>test</p>
                </article>
            </aside>

            <aside class="middle-sidebar">
                <article>
                <h2>Middle Sidebar</h2>
                <p>test</p>
                </article>
            </aside>                


</div>



</body>
</html>

Well, I can't comment.

But if you don't have a server support PHP you can't run the file.

I mean you can't run the file in your "PC" you need upload the file to web hosting or set up your computer as server. (You can install WampServer, XAMPP etc..)

Your code appears correct in format, but you cannot just display PHP code without a server. If you are testing this by opening the file in your browser, it will not work. You need to either look into XAMPP a useful cross platform server solution for free or if you have a hosting provider for a website, testing your code on that server. Hope that helps.

Here is some information on XAMPP .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM