PHP Features In This Lesson
- echo command
HTML Flashback Lesson #9 To Code in PHP
In lesson #9 in the beginners web development course we coded a website in HTML. We then displayed it in a browser to show you how HTML works. We are going to work off of that lesson and put it in PHP.
Section Off HTML
The way to think about this is to section off HTML. Most websites have a header, body and then a footer. So the top part anything above the opening body tag and including the body tag would be part of the header. Underneath the body tag clear to just before the closing body tag would be your main content. Then the closing body tag to the closing HTML tag would be your footer.
You can name your files like this in PHP.
Index.php File And The Include Function
You would then insert those files into the index.php by using the PHP include function. You index file would look something like this.
<?php include('header.php');?><?php include('main.php');?><?php include('footer.php');?>
Variables in PHP
In this lesson we set a variable and stored the menu items in it.
<?php $var=' <ul> <li><a href="foo.php">Foo</a></li> <li><a href="doo.php">Doo</a></li> </ul> '; echo $var; ?>
Conclusion of this PHP Lesson
The object of this lesson was to teach you that you can program something once and use it over and over again in your other files. There is no need to keep writing the same things over and over again.
I hope you are enjoying the process of learning to program in PHP. Please share these lessons so we can get the word out. 🙂
Please like, share and subscribe.
I hope you enjoyed the article. If I was able to help you please consider a tip for the content.
One Time Tip