1. Technology
Send to a Friend via Email

Video:Using PHP With HTML

with 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

  • All Videos
  • All Technology Videos
  • PHP/MySQL Videos

Transcript:Using PHP With HTML

Hi! I'm Don Schechter for About.com Computing. Today I will show you how to use HTML when coding PHP.

Begin a PHP File

First 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 HTML

There 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 Tags

Now 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 Code

However, 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 File

Now 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.
About videos are made available on an "as is" basis, subject to the User Agreement.

©2014 About.com. All rights reserved.