How to Write your First PHP Script And How To Put It Online For Free

ou want to learn how to write PHP scripts but don’t know where to start from? In this tutorial I’ll show you all what you’ll need to write your first PHP script. It is a lot easier to get started with than you might think.

What is PHP?

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.Its is a powerful tool for making dynamic and interactive Web pages.. By learning just a few simple functions, you are able to do a lot of things with your website. And once you know the basics, there are a wealth of scripts available on the internet that you only need to tweak a little to fit your needs


Tools To Get You Started

To start running PHP Scripts, you need a web server running PHP. In this Tutorial, i will show you 2 different ways you can run the PHP script 

1. A web host

2.Your Local computer

I will recommend the second option of running it locally, this is very easy and that was the exact way i learnt mine. Lets get started on both Options and you can choose anyone that is ok for

Run On Your Web-Host: Run php script on you web host, if you already  have your web host just upload php scripts on web server via FTP or file manager, I recommend , all you need to do is register and you are ready to write your php scripts. The advantage of this approach is that you don’t have to install anything; the disadvantage is that it’s slower to write and test your script.

Run PHP script on your own computer. There are many way to run php scripts locally , by my opinion the easiest way is to install a complete package like XAMPP. XAMPP is a great piece of software for a development machine, I highly recommend it. Be sure to have it not to start up when Windows starts, you can always turn it on manually when you need it. Here are detailed instruction How To Install XAMPP (The link allows you to download Xampp and installation instructions).

Download text editor: To write PHP code you’ll need text editor, I recommend  Notepad++ , you can download Notepad ++latest program here

Your First PHP Script

Every php script begins <?php with and ends with ?> . Below is example of simplest Hello World php script. PHP command echo is a means of outputting text to the web browser.


echo "Hello World";


How To Upload Php Scripts On XAMPP?

Install XAMPP and launch it. Open text editor as notepad ++ type your code and save as filename.php.



Go to folder where you installed XAMMP, default it’s C:/xampp , there you’ll find folder called htdocs , save you script myFirstScript.php to htdocs



How To Upload PHP Scripts On

 Login to your acc , open File manager.


Go to folder public_html and click upload, browse your php script


Launch web browser and type