How to Write a Simple PHP Script – 3 Quick Steps to Your First PHP Script

I’m going to show you the exact steps I took on how to write a simple PHP script. Everything you’ve read about how simple it is to create websites using PHP is very true.

In just a short while you’ll be able to install PHP, a powerful web server called Apache and a database software, MySQL in your local Windows machine. You don’t need to buy any web hosting yet and you can simulate everything you see in live websites in your local computer. But don’t get ahead of yourself. Important thing is to relax and let’s go step-by-step on how to write a simple PHP script.

Step 1 – Download WampServer

Get ready to go insane if you plan to install everything manually. The good guys at has a free WAMP (Windows, Apache, MySQL, PHP) installation package that will take out all the frustration when installing an environment for development.

Step 2 – Open Your Text Editor

You don’t really need to buy an expensive text editor. You can just search online for some of these free quality text editors. Or you can just use Notepad if you like.

Step 3 – Write a Simple Script

Create a new file and write the following code below. Save your file under C:-wamp-www and name it simple.php. The first line will basically output “Hello World” to your browser. The second line will display today’s date and the last line will output the information regarding your PHP installation. You can see all of this by opening up your browser and typing h t t p : / / localhost / simple.php

< ? php

echo “< p >Hello World< /p >”;

echo “< p > The date today is: “. date ( ” F j, Y” );

phpinfo () ;

? >


Source link