PHP is more or less a server-side programming language. It uses databases and other script-like variable, arrays, and functions to build an HTML page. PHP is server-side, so the server reads the script (the .php file) and runs through any functions to process, and then spits out the resulting HTML file. And, viewing source only shows the HTML part, it doesn't show the whole contents of the PHP file.
For instance, here is a very simple HTML web page.
Code:
<HTML>
<HEAD>
<TITLE>Very Simple Web Page</TITLE>
</HEAD>
<BODY>
Content goes here
</BODY>
</HTML>
Now, here's a PHP equivalent:
PHP Code:
<?php
echo "<HTML>
<HEAD>
<TITLE>Very Simple Web Page</TITLE>
</HEAD>
<BODY>
Content goes here
</BODY>
</HTML>";
?>
Even though it has some extra stuff like the php tags, and the echo tag, if you view the source on that web page, it only shows the HTML parts. So, you can have very lengthy backend PHP code, to make simple, yet dynamic HTML pages.
If you're wanting to learn to use PHP, just search on Google and you'll end up with oodles and oodles of tutorials.
Dave