Basic PHP Tutorial 3: HTML with PHP
Key Takeaways
Builds a PHP while loop
Full Transcript
hello and welcome to the third php tutorial in this tutorial we're going to be discussing uh putting html within php and then putting php within html so you've already seen us put html initially at least into php in the previous tutorial where we put the strong tags so first let me just show you throwing in a quick php script within an html script so what we're going to go ahead and do is make a quick just html input text box so and again if you're not too familiar with html just follow along um html is really really basic uh and there's plenty of tutorials i might have tutorials on html at some point if i do i'll just edit this and append or put up one of those little annotations or something but anyway we're going to put an input type equals text oops text and we'll say value equals and what value is is like what's going to be in that that text box initially like before someone actually types so that value what if we made that value be some sort of php script that derives the value so let's add php tags and let's make the script so there's our tags question mark php and then ends with a question mark closing tag and within those php tags let's say we want to echo the language so we'll just echo dollar sign lang for the for our variable that's defined up here as always with php end with the semicolon even though this is really one line so i guess you wouldn't have to end with that semicolon but you might as well get used to putting that semicolon so and at least i might as well get used to it so i'm going to keep doing it so anyway this is really html and then we've got a short but it is a php script within the html so with that let's save it and let me put this up on the server hopefully i didn't typo anything i like to typo and we'll run it and it says welcome to php oh we didn't remove that but that's okay but as you can see we've got this text box and the default value in this text box is indeed php but of course we can delete that and type whatever we want so let's pop back over here and let's get rid of this html or actually let's just change up the html a little bit and let's just say the value here is just html example and let me get rid of this echo and real quick let me pop this back onto the server so you can see what we're dealing with see this is html outside of the php now and there's no php within the html so this is just html but what we can do is we can throw this html within our php and that is going to be just echo and then you echo a string and what we're going to do is literally just copy and paste or actually cut and paste that to the echo now if you'll notice within this echo we've got um the text is kind of finicky here we've got this literally going black on us and that's because we encased everything in a quote so it gets this single quote and it thinks this is the end of the string and then at this point it's like what and then it's like okay we opened up at a quote again and then we've got double quotes and then things got really messy and so in fact what we can do is we can replace these double quotes with single quotes first off and then what you do is use the backslash it's above your enter or return key and you do that and it's called the escape character and you just escape all of these quotes that you don't want to actually hold you know a value of a quote so anyway after we've escaped all of those the other thing you can do instead of escaping all of these is just in case the entire echo statement in double quotes but for the most part i pretty much program everything in single quotes but anyway yeah the options are there for pretty much whatever you want to do um i'm pretty sure the standard usually is actually to code everything in single quotes and escape the inside quotes but i have seen people that will say you know hey you should really encase everything in double quotes but whatever anyway save that upload it back to the server and now as you can see we've got php script here and within it we're just echoing some html which will be read by the server and inputted most likely and we save it we see html example but let me just switch this up a little bit and say or html and php just so you know like it really did just get uploaded to the server and changed and we'll pop back over here save it or refresh and yeah so now you've got html within php so those are the basics of php within html and html within php you might decide to do it whatever way for a whole variety of reasons so um anyway hopefully you all enjoyed as always thanks for watching and until next time
Original Description
Link to the full playlist:
http://www.youtube.com/playlist?list=PLQVvvaa0QuDcYpcjrNB43_iKqla5UeQw_
Sentdex.com
Facebook.com/sentdex
Twitter.com/sentdex
How to put HTML within PHP and PHP within HTML
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from sentdex · sentdex · 23 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
▶
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
Python Encryption Tutorial with PyCrypto
sentdex
Python's Logging Function
sentdex
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
wxPython Programming Tutorial 4: Panels
sentdex
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
wxPython Programming Tutorial 8: Custom Button Images
sentdex
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
Basic PHP Tutorial 12: Associative Array
sentdex
Basic PHP Tutorial 14: Foreach loop
sentdex
Basic PHP Tutorial 16: Include and Require
sentdex
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
Basic PHP Tutorial 4: Variables and Comments
sentdex
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
Basic PHP Tutorial 1: Intro to PHP
sentdex
Basic PHP Tutorial 3: HTML with PHP
sentdex
Basic PHP Tutorial 9: While Loop
sentdex
Basic PHP Tutorial 10: Switch Statement
sentdex
Basic PHP Tutorial 2: Print and Echo
sentdex
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
Basic PHP Tutorial 19: Finding words in strings
sentdex
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
Basic PHP Programming Tutorial 24: String similarity
sentdex
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
Sikuli Tutorial 1: Visually programming in python!
sentdex
Sikuli Tutorial 2: Program visually in python!
sentdex
Sikuli Tutorial 3: Program visually in python!
sentdex
3D Bar Charts in Python and Matplotlib
sentdex
3D Plane wire frame Graph Chart in Python
sentdex
Raspberry Pi Part 1 Introduction
sentdex
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
Raspberry Pi Part 11: Remote Desktop
sentdex
Twitter Analysis: How to rank a user's influence
sentdex
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex
Related AI Lessons
⚡
⚡
⚡
⚡
X now offers an MCP server to make its platform easier for AI tools to use
TechCrunch AI
n8n Automation Repurpose Video Content: The 2025 Production Guide
Dev.to AI
You’re Still Paying $200/Month for AI Tools You Could Replace With a Free Local Setup Tonight
Medium · Data Science
Top 10 AI Tools Every College Student Should Know in 2026
Medium · AI
🎓
Tutor Explanation
DeepCamp AI