PHP is text in a file on a Web server. The text gives instructions to the server on how to create an HTML page. One clever thing about PHP is that you can mix it with HTML so your HTML and CSS skills can still be used but you can add scripting behind the scenes.
Open your HTML template in your editor and save it as phphtml.php in the folder with your other Beginner stuff (HTML, CSS, JavasScript). Note the extension has changed. If you did not do the HTML & CSS tutorials you might want to consider it as you need to know HTML and CSS before learning PHP. If you already know them just create an empty HTML page and use that as the template. Or paste this in and save it as _template.html:
Put some text in the h1 inside phphtml.php as usual and then add this code just after the h1 element:
<?php echo "<p>Hello world</p>"; ?>
The <?php marks the beginning of the PHP code and ?> is the end. It is in effect a very long tag with code inside.
If a Web server is asked for any HTML page it just packages it up and sends it out over the Internet to your browser. If you ask for any file with a .php extension the server knows it has to look inside for PHP code first. It looks for the code and runs it. Only when it has finished does it send the file out to the browser. The code inside the PHP tag is not sent to the browser so the user never sees it. They might see something generated by the code though.
What will it do?
This particular piece of code uses the command echo which repeats what is in the quotes after it. It repeats it into the Web page. So if you echo anything in PHP the user will see it in their browser. If you don't echo (or use other commands that do the same thing) they will not see anything. There is another command which does the same called print which some people prefer as it describes what is happening a bit better - it is printing the text to the Web page. They do the same.
Running the page
As explained you need to upload the page to a server now unless you are using XAMPP and have changed the document location to where the pages are saved. Connect to your server now (using FTP probably) and create a sub-folder to hold all of your work in PHP for this site. From now on upload all files for this tutorial to that folder and create other sub-folders for other work.
Once uploaded you need to open the page in a browser by typing the address of the server into the browser (localhost for XAMPP). If you do not have any pages called index, main or home on the server you should now see a list of all the files and folders in that particular location. You can click on the folders to go into them or on the files to open the pages. Click on phphtml.php. If you do not see any list of files you will need to manually type the page name at the end of the URL in your browser.
From now save, upload and view pages in the same way to test them.
In your browser you should see a mostly blank page with a heading you typed into the HTML and a paragraph which PHP created using echo. Right click on the page and choose View Source (or similar). You should see the paragraph as you would any other HTML paragraph and the same as the other HTML elements. PHP generated that HTML paragraph for you.
Save this page as _template.php so that you have a template ready to do PHP with. Delete the echo line and the h1 text to tidy up.