Sunday, December 18, 2011

Hello World PHP

Now that you have installed XAMPP on your windows 7 pc and you have set Apache to run as a service to work around an issue with running Apache on windows 7, you're now ready to write the standard Hello World application in PHP!  To do this, you will need to create the PHP file in your htdocs directory. This directory is in the xampp directory.  If you installed XAMPP according to the instructions for windows 7, it should be C:\xampp\htdocs. You can think of this as the inetpub\wwwroot directory in ASP.NET. This is where all of your web site files will go when you're developing locally.  Now create a new folder called "helloworld" inside the htdocs directory. Once you have created this folder, create a new file using notepad++ or any editor of your choice.  Enter the following text into this file:

<?php
    echo 'hello world!';
?>

Once you have entered this text, save the file to your C:\xampp\htdocs\helloworld directory that you created as "index.php".   Then start apache, if it isn't already started.  Next, open up your browser and navigate to http://localhost/helloworld.  You should then see a web page with the "hello world!" text displayed.  Congratulations!  You have just created your first PHP page.

No comments:

Post a Comment