How to create a PHP script

PHP is a general purpose scripting language that is well suited to web development and can be embedded into HTML. If you want to find out more about PHP take a look at is extensive online manual.

You can use any plain text editor to create a PHP script (e.g. Windows – notepad, Mac – textedit). Lets take a look a a very simple PHP script:

echo “Hello World!”;

Line 1 – This tag tells the server that you are writing PHP code

Line 2 – You can use the echo function to print out a string of text, this will be displayed back when the script is run.

Line 3 – This tag tells the server that you have stopped writing PHP code

Each line of PHP code is called a statement, and ends with a semi-colon to signify it is a complete statement.

Open your text editor and type the code above into it (without the line numbers), and save it to a file called hello_world.php.

Next upload your hello_world.php script to your web hosting using FTP.

Now load up the script in your web browser e.g. (replace with your domain name). If all goes well you should see ‘Hello world!’ at the top of your screen. If not check out the PHP Troubleshooting guide.

That’s it! You now know the basics for creating PHP scripts.

Was this article helpful?

Check out some of our related guides

Need a hand? Search over a hundred step-by-step support guides