Network sites: CSS - HTML - PHP - Or check the full directory
Is easy to understand - logo

Writing your first PHP code - Hello World

Almost every coding course starts with it, the all-famous Hello World program. All it needs to do is display the message "Hello World" on the screen using the language you are starting out to learn.

To get started you will need a text editor (not a word processor) and write the following lines in a new document:

Hello World
1
2
3
<?
echo "Hello World";
?>


Now save this file to the root of your webserver and name it 'helloworld.php'.
If you open up a webbrowser and browse to your local server appended with this filename (in many instances this will be http://localhost/helloworld.php when working on a testing server) you should only see "Hello World" if the screen remains empty it means that you will need to troubleshoot your server because it isn't interpreting the PHP code.

 

And there you are, you have just written your first piece of PHP code! Ofcourse you could write only the text to a file, but showing text is essential in coding and testing. In the following chapters we'll go further into the dynamics of PHP which make this (and any other language) so powerfull.


Post a comment

Any additions, questions or comments to this article are welcome, post a comment below for the maintainer so he can update the article.

 

Latest videos

  • No videos available yet

Full site directory

Copyright © 2012 DreamworX Media | Internet, code and innovations