This tutorial will introduce you to PHP with the customary Hello World script. You will be introduced to the echo language construct and the date() function. The goal of this tutorial is to show you how to output text, and display the current date.
I will not explicitly say save this as “file.php”, upload to your server, and access in your web browser, but it is strongly encouraged that you do so at each step.
To start, let’s output the text “Hello World” to the screen.
1 2 3 4 5 | <?php echo 'Hello World.'; ?> |
Any text placed within the quotes will be outputted to your screen when you access the script in your web browser.
Now, we are going to display the current date in addition to our greeting. We can get the current date using the date function which in this example takes one parameter, but usually takes two. We will discuss that in a future tutorial, but the other parameter is a standard Unix timestamp – the number of seconds since 00:00:00 UTC on January 1, 1970. We do not need to specify it here since the date function will assume I am after today’s date by default.
1 2 3 4 5 | <?php echo date('d/m/Y'); ?> |
The above will output the current date to the screen. The one parameter taken is what defines the format in which our date is returned. The page for date() in the PHP manual has all you need to know about the various ways in which you can format the date.
Now that we have learned how to output some text of our choice, and retrieve today’s date, let’s combine the two.
1 2 3 4 5 | <?php echo 'Hello World. Today\'s date is ',date('d/m/Y'),'.'; ?> |
You should notice the backslash preceding the single quote in “Today’s”. This is called escaping and tells PHP to ignore the character and continue on. It will be discussed in much more detail in a tutorial later in this series.
NOTE: These tutorials may seem like they are assuming too much knowledge at this point, but you will eventually see that this is by design, and that anything not covered and assumed will be covered in tutorials yet to be written or published. The goal is to have a series of related and dependant tutorials, but at this point I am not writing them in order. The tutorial page will always have the tutorials listed in the intended reading order.
Chris is a freelance web developer and founder of 




Pingback: clear skin max
Pingback: bad credit small business loans
Pingback: facebook for sex
Pingback: Learn About Some Great Winning Lottery Strategies
Pingback: berkeyshop.com
Pingback: plus size swimdresses
Pingback: Click here for pre workout supplements
Pingback: baby bean bag chair
Pingback: Alerid (made in EU) - 60 tab., 10 mg. - Allergy - 24/7 Med
Pingback: game
Pingback: Lofts in Downtown Los Angeles
Pingback: broadcasting tower
Pingback: cellular on wheels
Pingback: follow link for more information
Pingback: One Hour A Day To Wealth
Pingback: Bigfoot The Movie Trailer
Pingback: wheatgrass powder benefits
Pingback: team building
Pingback: Sex webcam
Pingback: San Diego Company Picnic
Pingback: articles on innovation
Pingback: Phoenix Newborhood
Pingback: pea coats for men
Pingback: aquasana shower filter
Pingback: we buy test strips
Pingback: creation site web gratuit
Pingback: creation site web geneve une agence
Pingback: webmaster annecy
Pingback: creation site internet tonon
Pingback: creation site internet geneve une agence
Pingback: creation site internet gratuit
Pingback: Creation Site Internet Annecy
Pingback: tires and wheels online
Pingback: kawosz
Pingback: How to Tie a Tie
Pingback: Juegos online de futbol gratis
Pingback: vitamins
Pingback: Software
Pingback: Computers
Pingback: sub zero parts 550
Pingback: visit
Pingback: how to make money
Pingback: date taiwanese woman