Basic “Hello World” PHP Script
Ok, as anyone that has programmed before knows, the first program you typically make is the infamous “Hello World” program. This simple program will show the basics of an output script and is a great starting block for anyone beginning a new language.
First I will show the code and then I will break it down a little.
<?php
echo "Hello world.";
?>
Ok now for the breakdown:
<?php
This is the opening tag that tells the server that the following code should be parsed by the web server before sending the information to the client that is accessing the website.
echo "Hello world.";
The echo command is used to print information to the screen. This can be used to print text, variables, or variable arrays. In this case we are printing Hello world. to the screen.
?>
This is the closing tag that tells the server that it should stop parsing the code with php and that it should return the next bit of code as normal html.
Now that was simple wasn’t it? With this simple bit of code you can have a white page with the line Hello world. printed on the screen.
Discussion Area - Leave a Comment