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 PHP Basics PHP on the Web Combining Multiple Files with Includes

Hello I'm at the portion of the video to include the units.php file and I'm not able to get it to show. (I did save)

<section class="main"> <h1>My First PHP Page</h1>

      <h2>Unit Conversion</h2>
<?php include 'inc/units.php';?>
      <hr />

      <h2>Daily Exercise</h2>
    </section>

https://w.trhou.se/tqjibmk46h

If someone could tell me where I went wrong I'd appreciate it.

3 Answers

You need to spell the directory correctly - it is case sensitive.

I'm having the same issue.

The code above has a lower case "i" for the Inc directory and in that workspace (follow that link) the folder has an uppercase "I" - if you fork the workspace and change the code to an upper case "I" it works as expected. (or rename the directory)

<?php include 'Inc/units.php';?>
christopher foley
christopher foley
582 Points

I had a problem with this, hopefully this helps anyone else who made my same mistake.

When I created the inc folder I put all the extra files in the inc folder, including the index.php file. You should leave the index.php file in the main directory (outside any folder), and put all the rest of the files from the main directory (exercise.php, hello.php, numbers.php, strings.php, units.php) into the inc folder, then after that it will work properly.

Hope this helps anyone who had the same issue.