Scroll down to the script below, click on any sentence (including terminal blocks!) to jump to that spot in the video!
If you liked what you've learned so far, dive in!
Subscribe to get access to this tutorial plus
video, code and script downloads.
Ok, let’s improve one more thing by giving contact.php the same HTML layout as our homepage. To do this, just isolate the header and footer into their own files, say layout/header.php and layout/footer.php. Move all of the HTML from the top of the index page into header and the stuff from the bottom into footer:
<!-- layout/header.php --> <!DOCTYPE html> <html lang="en"> <head>...</head> <body> <!-- header code here... -->
<!-- layout/footer.php --> <footer>...</footer> </body> </html>
Require the header near the top of each page and the footer after our page-specific code:
<?php // index.php // ... the big PHP code block at the top ?> <?php require 'layout/header.php'; ?> <!-- all of the HTML and PHP code from the middle ...--> <?php require 'layout/footer.php'; ?>
Repeat the same thing in the contact.php file.
And just like that, our two pages are sharing the layout!
Woh! You just learned a ton: coming from the basics of PHP to using arrays, functions, foreach loops, complex if statements, true/false boolean values, user-defined functions, require statements and more. We also got your system setup so that you can develop and try your own code locally.
So congratulations, but keep going! There’s so much more that we need to cover, like how to submit a form, talk to a database, and use query parameters. And to be serious developers, we also need to organize our project better. As nice as the functions.php, header.php, and footer.php files are, real developers organize things in more sophisticated ways. But keep working and we’ll get there!
See ya next time!
Hey Serhii R.
Welcome to SymfonyCasts, I'm glad you find our tutorials useful :)
About files location, we usually mention where a file lives, or at least show the full path of a file in the code blocks (down in the script). My apologies if it wasn't very clear in this video. Actually, this tutorial is missing a few features due to technical reasons, if you go to a more recent tutorial you'll notice that you can click on the script to play the video exactly at that point. Also, the script contains expandable code blocks, video subtitles in English and Spanish, and a few other useful things :)
Really glad to have reached this far and am still pushing on!Thank you GUYS!
Yo! We are happy to hear it! Thanks for being with us!
Cheers and happy coding!
"Houston: no signs of life"
Start the conversation!
Hi everyone! Sorry, but how I should guess where the header.php and footer.php are located? I noticed this small bottom line only after I had made a mistake. Could you make it more conspicuous, please? Or give a more detailed description of file locations. By the way, the course is amazing! I think if I had subscribed to symfonycasts earlier I would have learned PHP faster. Thanks for your time spent creating this!