PHP - Hello World Example

Today, we are starting the PHP examples series. Almost every programming class, book or a tutorial starts with the Hello World example.
We are going to honor this tradition by making Hello World our first PHP example in this series.

This is your first PHP application.
As you can see, you must escape PHP code from HTML with

<? PHP Code here ?>

Another one, commonly used is

<?php PHP Code here ?>

echo is a command for printing messages.

Example Code:

<html>
  <head>
    <title>
<?  echo "Hello, World!!!"?>
    </title>
  </head>
  <body>
<?php  echo "Hello, World!!!"?>
  </body>
</html>

Congratulations. Your have just written your first PHP application!

Related Marakana Courses

  • PHP and MySQL Bootcamp Training

2 Responses to “PHP - Hello World Example”

  1. Anon Says:

    Tried this, but Firefox just opens a window saying do you want to view the file test.php?

    so you're not telling the whole story dude, what else do you need to do to get this working?

  2. h4ckingURLife Says:

    Hello Anon.
    Did you save the file as .php? Even though it has html in it, still needs to be saved as .php to make everything work.

    Regards h4ckingURLife.

Leave a Reply