Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Build a Simple PHP Application Creating the Menu and Footer Including the Footer and Adding Additional Pages

Elena Paraschiv
Elena Paraschiv
9,938 Points

comment in php file does not work

I tried to write a comment in the index.php file like this
//comment
and it didn't work out
then I tried to write it in Html format  
<!-- coment  -->   

and it worked

Why if the file is .php ?

3 Answers

It looks like your comment isn't inside of a PHP block. (make sure it is on its own line as doing it as a one liner will break)

<?php

 //try it this way

?>


<?php //this will break ?>
Elena Paraschiv
Elena Paraschiv
9,938 Points

Yess. That made it. Thanks Luke :)

Could you paste all of the code from that page? It is possible that code before the comment is causing it to not work correctly.

Elena Paraschiv
Elena Paraschiv
9,938 Points
<?php include ('include/header.php');  ?>

        <div class="section banner">

            <div class="wrapper">

                <img class="hero" src="img/mike-the-frog.png" alt="Mike the Frog says:">
                <div class="button">
                    <a href="#">
                        <h2>Hey, I&rsquo;m Mike!</h2>
                        <p>Check Out My Shirts</p>
                    </a>
                </div>
            </div>

        </div>

        <div class="section shirts latest">

            <div class="wrapper">

                <h2>Mike&rsquo;s Latest Shirts</h2>

                <ul class="products">
                    <li><a href="#">
                            <img src="img/shirts/shirt-108.jpg">
                            <p>View Details</p>
                        </a>
                    </li><li>
                        <a href="#">
                            <img src="img/shirts/shirt-107.jpg">
                            <p>View Details</p>
                        </a>
                    </li><li>
                        <a href="#">
                            <img src="img/shirts/shirt-106.jpg">
                            <p>View Details</p>
                        </a>
                    </li><li>
                        <a href="#">
                            <img src="img/shirts/shirt-105.jpg">
                            <p>View Details</p>
                        </a>
                    </li>                               
                </ul>

            </div>

        </div>

    <?php include('include/footer.php'); ?> 
    //hi I am a comment :)