PHP include statements not executing on Ubuntu 12.04

I am configuring PHP for the first time on my Ubuntu 12.04 distro and am not able to render my foo.php file to render any of the files attached with an include statement. For example, I have header.php and footer.php referenced in foo.php with <?php include ‘header.php’; ?>.

I can get a phpinfo file to run via <?php phpinfo(); ?> in an info.php file, but when I hit foo.php, the include statements seem to not be rendering on the server.

Any thoughts?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

You’re trying to include files from <pre>/templates</pre> which doesn’t exist. You have to either use relative paths (./templates/header.php) or absolute paths (/var/www/templates/header.php).

:( And since I’m not able to edit my posts, here’s a better representation of the folder hierarchy: <br> <br>/www <br>----index.php <br>----/templates <br>------------header.php <br>------------footer.php

Sure thing. <br> <br>Header - <br>Body - <br>Footer - <br> <br>Also, my folder hierarchy is setup like this: <br> <br>/www <br> -/html <br> -index.php <br> -/templates <br> -header.php <br> -footer.php <br>