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 Starting the Project

Bryn Humphreys
Bryn Humphreys
26,472 Points

No display when I rename the index.html file to index.php

I'm in the PHP Shirts 4 Mike project and at the start we are told to change the index.html file to index.php When I do this nothing displays in the browser. I have tried many browsers same result

11 Answers

Bryn,

Found your problem for your index.php file.

<p>&copy;<?php echo date ('Y') "Shirts 4 Mike"; ?> </p>

Should be:

<p>&copy;<?php echo date('Y'); ?> Shirts 4 Mike </p>

Change this and your page should display.

Cheers!

Bryn,

Can you please display the code that you have. There maybe a syntactical error preventing your page from displaying. also, what web server application are you using and is it turned on. You may be using a web server application (like Wamp or XXAMP) but not all the services may be on.

Cheers!

Bryn Humphreys
Bryn Humphreys
26,472 Points

Hi Sean,

Thanks for your reply!

I am using MAMP and here is my code:

<!DOCTYPE html> <html> <head> <title><? php echo "Shirts 4 Mike"; ?></title> <link rel="stylesheet" href="css/style.css" type="text/css"> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Oswald:400,700" type="text/css"> <link rel="shortcut icon" href="favicon.ico"> </head> <body>

<div class="header">

    <div class="wrapper">

        <h1 class="branding-title"><a href="./">Shirts 4 Mike</a></h1>

        <ul class="nav">
            <li class="shirts"><a href="#">Shirts</a></li>
            <li class="contact"><a href="#">Contact</a></li>
            <li class="cart"><a href="#">Shopping Cart</a></li>
        </ul>

    </div>

</div>

<div id="content">

    <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>

</div>

<div class="footer">

    <div class="wrapper">

        <ul>        
            <li><a href="http://twitter.com/treehouse">Twitter</a></li>
            <li><a href="https://www.facebook.com/TeamTreehouse">Facebook</a></li>
        </ul>

        <p>&copy;<?php echo date ('Y') "Shirts 4 Mike"; ?> </p>

    </div>

</div>

</body> </html>

Bryn,

The opening tag for PHP is <?php. You have a space between the ? and php. Remove the space and try to view your page again. This should fix your issue.

Cheers!

Bryn Humphreys
Bryn Humphreys
26,472 Points

Hi Shawn,

I made the change and still no display.

Bryn.

Bryn Humphreys
Bryn Humphreys
26,472 Points

It works fine when it is a .html file but as soon as I change it to a .php file there is now display and if you try to view the code using chrome there is no code.

Bryn Humphreys
Bryn Humphreys
26,472 Points

It works fine when it is a .html file but as soon as I change it to a .php file there is now display and if you try to view the code using chrome there is no code.

Bryn,

Aside from making sure that the file is in the root directory of your web server and that you are using http://localhost/index.php, the only thing I can think of is that PHP isn't parsing like it should. Do this:

Create another file in your root directory and name it info.php. Inside the file add the following code:

<?php
echo phpinfo();
?>

Once you saved the file, go to a browser and type into the URL localhost/info.php and see if anything gets displayed. If nothing gets displayed, PHP isn't active on your system or you accidentally didn't install it properly. If this is the case: first try and restart the MAMP service and see if that fixes the issue; otherwise, you may need to uninstall and reinstall MAMP to see if that fixes it. If the info.php file displays the information about your version of PHP, there is something else wrong with your index.php file. Let me know what you get.

Cheers!

Bryn Humphreys
Bryn Humphreys
26,472 Points

Hey Shawn,

I ran the info.php file and received a whole lot of information about php such as system, build date etc.

Bryn (ps thanks for helping me)

Bryn Humphreys
Bryn Humphreys
26,472 Points

Hey Shawn,

I ran the info.php file and received a whole lot of information about php such as system, build date etc.

Bryn (ps thanks for helping me)

Bryn Humphreys
Bryn Humphreys
26,472 Points

I love you! That was driving me crazy!

Thanks Shawn.