First off remember that PHP pages are not limited to purely writing PHP code. The PHP code is only inside of the <?php and ?> tags. Anything outside of those tags would not be PHP and could be anything that you could normally write in an HTML file. With a standard PHP file that is not going to be used as an include, you will have html tags in the file.

I am sure you know something about file types if you have made it this far. Simply put, make sure your files have the .php extension or else the server won’t process the code. If PHP is your first language other than HTML, CSS, and JavaScript, you will realize that PHP isn’t nearly as forgiving. Be consistent and use the proper syntax. Enough chatter, let’s write our first PHP script!

        <h3>My First PHP Code</h3>
            echo "I am awesome!";

I am awesome!

The command echo is one of the ways PHP can output content. So, basically we used the opening <?php tag to indicate that were starting to use PHP code. Then, we echo a string “I am awesome!”, which you are. And of course, we end our only statement with a standard ;. Finally, we tell the server that we no longer want to use PHP code and we close it with the ?> tag.

If you have this idea mastered, continue on to learn about the fundamental stones to craft a master PHP website.

If you enjoyed this resource, support me by sharing this page with others.
Share on Facebook
Share on StumbleUpon
Digg this
Tweet about this on Twitter
Share on Reddit

Leave a Comment

  1. Just had a quick question.

    Do HTA’s support PHP? I tried running a function using an input button, but when I try running the function I get an alert saying that "PHPTest() is null."

    This is what I have written:

    <title>New HTA</title>
    <HTA: Application>
    <link rel="stylesheet" type="text/css" href="C:\Styles\style.css">


    function PHPTest()
    echo "PHP Test";


    <body bgcolor="lightsteelblue">
    <div class="button_format">
    <input type="button" name="phptestbutton" value="PHP Test" onClick="PHPTest()">


    I also tried writing:


    echo "Test"


    inside the "body" tags, but still nothing. Anyone have any advice?

  2. Is the php supposed to be on multiple lines like that? It doesn’t seem to be working for me following the same format :p

  3. Is the php supposed to be on multiple lines like that? It doesn’t seem to be working for me following the same format :p

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.