Video:Using PHP With HTMLwith Don Schechter
There are a couple ways to include HTML when coding PHP. Learn two options that work equally well, then decide which one makes the code more clear and concise for you.See Transcript
Transcript:Using PHP With HTMLHi! I'm Don Schechter for About.com Computing. Today I will show you how to use HTML when coding PHP.
Begin a PHP FileFirst let me open a new Notepad document. Go to 'file, save as' and give it a name, and make sure to add the extension .php
Use Standard HTMLThere are different ways you can incorporate HTML. Let's start by just including the standard html tag, along with the title and body tags. Do not forget their end tags. I'll quickly create a paragraph tag with some text. You can add any HTML tags you like.
Add in PHP TagsNow create a PHP tag with some code. I will type echo and, in quotes, This is my PHP text. I'll also add a semicolon so I can add more lines later. This is an easy way to use both HTML and PHP side by side.
HTML Within PHP CodeHowever, you can include HTML tags within your PHP code. This is convenient when you don't have long lines of HTML code you want to include.
Under my PHP echo code, I'll add another echo line. Within the quotes we can add more text - My PHP Header. We can put HTML tags directly within the quotes. I'll add a header tag. Don't forget to close the tag and end with a semicolon.
I will add another echo with, in quotes, an HTML break tag and a semicolon. I will copy and paste the code a few times and add a final echo with Goodbye in quotes
View the HTML / PHP FileNow I will save my file and upload it via FTP to my website. Let me open up my Web browser and, once I type in the URL of the file, we can see what we just coded.
Both ways of including HTML work equally well, it is just a matter of personal choice and what will make your code more clear and concise. Thanks for watching. For more information, visit us online at computing.about.com.