From the course: PHP for Non-Programmers
Unlock the full course today
Join today to access over 25,200 courses taught by industry experts.
Output: Printing with HTML - PHP Tutorial
From the course: PHP for Non-Programmers
Output: Printing with HTML
- [Instructor] We can print PHP right alongside HTML. Your server will be smart enough to process the PHP and ignore the HTML, then send the results to the user. Let's refactor the coin flip project using HTML instead of just PHP. So you could see, I have the starting state for one of our repos. The only thing I've done is delete the hello world line. So let's add a heading one tag here. We'll say Flip a Coin, and then I will also update the title to say that. Next, let's add our PHP. So we can embed our PHP right in our HTML with an opening PHP tag, and then first we'll set our keep_going variable. Next, we'll create our while-loop to keep flipping the coin as long as the user wants. So we'll say while y equals keep_going, and then we'll add our curly braces. Now, here, we want the heads or tails to print inside of a paragraph. So we will create the closing PHP tag here, and then we'll write HTML. Again, we…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.